我用这段代码将第一个“替换为”,第二个替换为“”,一切正常,除了它在读取最后一个字符后再次运行循环,这使得程序打印另一个字符
#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();
}