i need some help with writing all the words in a text file (separate by space) into a linked list then print the content of the linked list!!
here is my code for word separated by a line break!! but i want help with the words separated by spaces...
Code:
FILE* f;
f = fopen("test.txt", "r");
char word[20];
int count = 0;
if (f == null)
{
perror("ERROR: \n");
}
else
{
while (feof(f) == 0)
{
fgets(word,20,f);
count++;
printf("%s", word);
}
}
fclose(f);
why does it also print out the last word twice?? :/
your help will be appreciated!!