我正在尝试在 do while 函数中运行一些代码:
do {
printf("\nThis game has two different modes: I Guess, You Guess\n");
Sleep(2000);
printf("Which mode do you want to play?\n");
cin >> mStr;
cout << "Are you sure you want to play " << mStr << " mode?";
cin >> choice;
} while (choice != "No");
但是,每次我输入 mStr (一个字符数组)时,它都会重新启动。它甚至不执行 cout。
以下是调用的 char 数组:
char mStr[10];
char choice[4];
在旁注中,我怎么能使用 printf() 而不是 cout 呢?我正在努力练习。
编辑:
这是新代码:
do {
printf("\nThis game has two different modes: I Guess, You Guess\n");
Sleep(2000);
printf("Which mode do you want to play?\n");
cin >> mStr;
printf("Are you sure you want to play %s mode?", mStr); //Cuts off here and doesnt display the 'Guess' part of I Guess
cin >> choice;
} while (strcmp(cKey, choice) != 1);