我有以下代碼:故障與scanf函數(C)
struct punto richiedi_punto() {
static int count=1;
struct punto point;
do {
printf("Inserire coordinate del punto %i:", count);
scanf("%d;%d",&point.x,&point.y);
} while (point.x<0 || point.x>9 || point.y<0 || point.y>9);
count++;
return point;
}
GCC不發現錯誤,但我得到這樣的警告:
Warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
我試圖找出一個解決方案在谷歌,但我不明白是什麼原因導致此警告。
在此先感謝。
編輯:我注意到,如果我在MonoDevelop控制檯中運行我的程序,我無法插入我的座標(爲什麼?),但是如果我在gnome-terminal中運行它,它通常工作。
從scanf中刪除';'(在2%之間) – 2015-04-03 10:47:15
什麼是x和y的類型?你能給完整的代碼嗎? – Mukit09 2015-04-03 10:47:32
@karma_geek,爲什麼? – 2015-04-03 11:50:13