我有以下代码:故障与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