0

これはmain()の終わりに向かっての私のコードです:

printf("Would you like to find data on another 20 rods? \nType C and press enter to continue, or type E and press enter to exit \n");

scanf("%s",&exitOption);

if (exitOption == 'C'){
main();

}

return 0;   

プログラムを実行するたびに、次のエラーが発生します。

ここに画像の説明を入力してください

なんで?どうすれば修正できますか?

4

1 に答える 1

3

exitOptionは文字である必要があります

scanf("%c",&exitOption);

文字列を取得しようとしている場合でも、この方法である必要があります

char string[10];
printf("Enter string\n");
scanf("%s",string);  // note the second parameter of scanf() when u get a string
于 2013-01-20T04:12:12.543 に答える