I’m having a variable called username and another one called password…
I need to register users into a system, and write it on a file..
My problem is, that the 2nd time or more, it writes the details on the same line..
For example :
in the first time I write for the file, it become something like this :
Amit 123456
but on the second time I’m registering a user, it doesnt go to the next line and keep writing from that spot:
Amit 123456Yosi 125818
where I need the file to be like this :
Amit 123456
Yosi 125818
I mean, I need to make the 2nd or more fprintf to the file go to the next line, and not to start from the specific place…
I’ve wrote this in the code :
fprintf(file, "%s %s\n", username, password);
though, the '\n'doesnt seems to make the next fprintf go to the next line…
In summery – I need to print to the file every time, on a new line..
on the first print to the file, it’ll write on line 1
then on the second print to the file, it’ll write on line 2, and not from the continue of line1…
Thanks 🙂
Had the same thought as the commenters: You may need a
\rin there too, depending on your development environment. It could even be that the file viewer you are using is the issue (eg: Notepad.exe on Windows often has trouble with simple line endings)