Quote Originally Posted by Ayreon View Post
After you type the filename on screen you press enter to continue, so isn't that always a newline? It does work now bytheway.
Yes, but if what you enter is longer the the buffer, fgets will read only the number of characters in your buffer and stop. That means it will not read the entire line, so the newline won't be in the buffer.

Could you help me with another problem too? It's still about the same program, I could make a new thread, but before you know this whole forum is stuffed with my questions...

I'm having trouble constructing a loop that keeps asking for a filename until the filename given, exists.
This is what I came up with, but crashes once you give the filename that exists (after giving an incorrect one):
It would help if you showed how you define datafile and filenames.
And why do you copy over datafile to filenames anyway? If that's the case, you can read directly into filenames[0].