|
发表于 2022-10-2 07:49:13
|
显示全部楼层
- a.c:8:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
- scanf("%d %d",&l,&m);
- ^~~~~~~~~~~~~~~~~~~~
- a.c:12:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
- scanf("%d %d",&a[i],&a[i+1]);
- ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
复制代码
翻译:
- a.c:8:2: 警告:忽略'scanf'的返回值, 用属性 未使用的返回值 声明[警告 未使用的返回值]
复制代码
这种警告一般可以忽略,不是报错一般就没事
小甲鱼老师讲过,编译结果一般有两种反馈结果
1.报错,是指语法错误等无法编译的代码
2.警告,是指代码可能有问题(我说的是可能,可能是某些无意义的代码,如声明了number却没有使用等)
如果真的不想看见警告,那么请关闭该选项开关,否则你只能这样写代码了:
- #include <stdio.h>
- int main() {
- int _printf_return_value, _scanf_return_value, n;
- _scanf_return_value = scanf("%d", &n);
- _printf_return_value = printf("%d\n", n);
- return 0;
- }
复制代码 |
|