I'm trying to eliminate any double whitespace, tab, or newline, or any combination of the two in succession from a file (leaving the old one the same and creating a new one). For some reason this seems to just be skipping the else statement where I expected it to write to the new file. the new file is appearing, but there is nothing written into it.
Code:
while( fscanf(inputFile, "%c", ¤tCharRead) == 1 )
{
if((currentCharRead == ' ' || currentCharRead == ' ' || currentCharRead == '\n') &&
(lastCharRead == ' ' || lastCharRead == ' ' || lastCharRead == '\n'));
else{
fprintf(outputFile, "%c", currentCharRead);
}
lastCharRead = currentCharRead;
}
What am I doing wrong?
thanks