我不知道爲什麼這不起作用,我需要交換兩個字符輸入爲A和B,它編譯,但所有的字符被替換爲B輸入的字符,任何意見?字符交換在一個文件C++
while (n != exist)
{
cout<<"What is the letter you want to swap?"<<endl;
cin>>a;
cout<<"What is the letter you want to swap it with?"<<endl;
cin>>b;
if (inFile.is_open())
{
while (inFile.good())
{
inFile.get(c);
if(c = a)
{
outFile<< b;
}
else if (c = b)
{
outFile<< a;
}
else
{
outFile<< c;
}
}
}
else
{
cout<<"Please run the decrypt."<<endl;
}
cout<<"Another letter? <n> to stop swapping"<<endl;
cin>>n;
}
謝謝你爲什麼我沒有看到我沒有想法,因爲我想要它! – Dom 2011-12-13 18:34:16
我想你回答了第一個病人標記urs作爲答案 – Dom 2011-12-13 18:37:17
@DominicBarrett:你可能想研究一下你的編譯警告來指出這種錯誤。 – 2011-12-13 19:07:32