Cprogramming.com: FAQ
And what does not appended correctly mean, exactly?
Printable View
Cprogramming.com: FAQ
And what does not appended correctly mean, exactly?
Do not use feof() to control loops!
Use your read function to check if it was possible to read or not.Code:while(!feof(log))
--
Mats
FYI, it's a terrible idea to write a message board with C.
It's basically like opening the web server up to the world with the thousand of bugs you're introducing (either knowingly or not).
So if you plan to use this... don't :)
I totally agree. You can't write any real programs in C! It's just for hello world!
Quzah.
Now why is it that if I suggested that, I would get people breathing down my neck, and yet here two people are suggesting that this should not be done in C?
I totally agree, though.
That was sarcasm actually.
Quzah.
I see. It was fun to see anyway, though.
As long as there are no bugs though, there are no security vulnerabilities. Btw, does anybody know how to prevent the error where the message board can't access the text file because Apache doesn't allow it? That's really the last step to finishing the message board.
Now we just have to hope that test programs don't become part of programs that people use....
do not use feof to control loop - read faq
use return value of fgets instead
fopen will either fail or succeed. No error will be printed by Apache.
If the program crashes, however, you can be sure you will get an error.
Therefore, properly check the return of fopen to make sure you don't call any other file functions if it didn't succeed. Then you can choose what you want to do about it.