Quote:
Originally posted by Mick
would you like me to explain?
first off what he posted as code snippets, and what he posted as the .zip are two different things, we could have been here all day, had the .zip not been posted.
Lets take a look at what happens in the if clause.
because of precedence the function fopen in the if clause gets executed first, it returns a valid handle and places it in file. It then test to see if file is null, this is false, it is valid, it will then JNE (jump if not equal) to the next clause the else if.
It will again, execute the fopen, and push a NEW file handle into file, we now have two file handles open to the same file, one of which is 'dangling' it then tests if the file handle is not null, it isn't so we drop into the block and execute the stat etc.
the remove(...) will fail as there is still an open file handle.
though I normally don't make these types of comments....but the code should be re-written, it's a big pile of steaming noodles.
EDIT: fixed some typo's, get real, you think I'm going to fix my grammer...sheez..what were you thinking????
I absolutely agree with you tat he should change the WAY he wrote his code for its readability..