Possible Duplicate:
Why is iostream::eof inside a loop condition considered wrong?
i used this code to replace the first " with `` and the second one with '' everything works just fine except it runs through the loop one more time after the last character is read and that makes the program print another character
#include <fstream>
#include <iostream>
using namespace std ;
void main ()
{
ifstream infile;
infile.open("infile.txt");
ofstream outfile;
outfile.open("outfile.txt");
char c ;
int i = 0 ;
while ( !infile.eof() )
{
infile.get(c)
if (c=='\"')
{
i++ ;
if (i%2==0)
outfile<<"\'\'";
else
outfile<<"``";
}
else
outfile<<c;
}
outfile.close();
infile.close();
}