我想讀1個字符和2個整數沒有成功。閱讀1個char和2個整數與scanf函數
的C代碼:
char action; int cr,cc;
printf("Enter 'c <row> <column>' to click on a block.\n");
scanf("%c %d %d",&action,&cr,&cc);
printf("You typed: %c %d %d\n",action,cr,cc);
端子輸出:(實施例)
Enter 'c <row> <column>' to click on a block.
c 3 3
You typed:
0 0
我用gcc編譯它(Ubuntu的5.3.1-14ubuntu2.1)5.3.1 20160413在Ubuntu 16.04 LTS 。
請附上您的變量的聲明 – Fazlin
嘗試'的scanf( 「%C%d%d」,&行動,與CR,&cc);' – BLUEPIXY
http://stackoverflow.com/questions/38343113/why-is-the-below-代碼未掃描所有的投入,正確#comment64105936_38343113 –