好的..所以我有那个代码,但我无法正确执行 Do While 语句......
#include <stdio.h>
#include <stdlib.h>
int main ()
{
int nWinsPC, nWinsPlayer;
char cChoose[1];
do {
system("cls");
printf("Vamos jogar um jogo?\n");
printf("-\n");
printf("Escolha (p)edra, p(a)pel ou (t)esoura: ");
getchar();
scanf("%1[^\n]", cChoose);
} while(cChoose != "p");
system("pause");
}
那个系统应该很简单......当玩家没有输入“p”时,选择屏幕保持循环,但我无法让它工作......
:(
提前致谢
编辑
问题解决了:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ()
{
int nWinsPC, nWinsPlayer;
char cChoose[2];
do {
system("cls");
printf("Vamos jogar um jogo?\n");
printf("-\n");
printf("Escolha (p)edra, p(a)pel ou (t)esoura: ");
scanf("%s", cChoose);
} while ( strcmp(cChoose,"p") );
system("pause");
}