'Program prints text files that are written as a list, one word on different line, how could I combine each line into one line?

This program reads and prints couple text files, they all are written as lists, one word per line, how could i print them all in one line with a space in between? and also how could i use currentsize and maxsize instead of 25?

char ** populate(char ** words, FILE *fptr, int *currentsize, int *maxsize)

{

for (int i = 0; i < 25; i++)

{
    words[i] - (char *) malloc(sizeof(char)* LIMIT);
    fgets(words[i], 25, fptr);

}

for(int i = 0; i < 25; i++)

{
    printf("%s", words[i]);
}

return words;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source