私はこのプログラムを使用してモノラルアルファベット暗号を実装しています。私が得ている問題は、プレーンテキストを入力したときに、Enterキーを押している条件が満たされたときにループから抜け出せないことです。これが私のコードです。
int main()
{
system("cls");
cout << "Enter the plain text you want to encrypt";
k = 0;
while(1)
{
ch = getche();
if(ch == '\n')
{
break; // here is the problem program not getting out of the loop
}
for(i = 0; i < 26; i++)
{
if(arr[i] == ch)
{
ch = key[i];
}
}
string[k] = ch;
k++;
}
for(i = 0;i < k; i++)
{
cout << string[i];
}
getch();
return 0;
}