私はこれがうまくいかない理由を知りません、私はaとbとして2つのchars enterdを交換する必要がありますが、コンパイルしますが、すべてのcharsはbと入力されたcharと置き換えられます。あなたが==
代わりの=
を使用する必要がcharスワップファイル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
あなたは答えとして最初のill mark ursに答えていると思います。 – Dom
@DominicBarrett:この種のエラーを指摘するために、コンパイルの警告を出すことができます。 –