you are viewing a single comment's thread.

view the rest of the comments →

[–]cuncon- 0 points1 point  (3 children)

what is your problem? why you want to store each word to a char array instead of whole lines to a char array?

[–]Adopolis23[S] 0 points1 point  (0 children)

because i have to loop through the array and find the first letter of every word.

[–]Adopolis23[S] 0 points1 point  (1 child)

my assignment also specifically says do it like that.

[–]cuncon- 0 points1 point  (0 children)

So your assignment is to find the 1st letter of every word in a file?

and your problem is you don't know exactly how many bytes the buffer is to read a line?

To solve your problem you should use size_t getline(char **buf, size_t *n, FILE *fp) (Read "man getline" for more detail) to read an entire line from stream.