Skip to main content
1 of 2
ChrisG
  • 7.4k
  • 2
  • 17
  • 26

There is one mistake here:

while (fgetc(ptr) != EOF)

doesn't just work as a condition, but it does read a char and moves on, so next time you read a string it's gonna miss the first char of the word because it was read by fgetc(). Fix that and report back. I would suggest you use the fscanf() in your loop condition instead (but then remove it from inside the body of the loop).

ChrisG
  • 7.4k
  • 2
  • 17
  • 26