【发布时间】:2022-01-20 08:39:28
【问题描述】:
#include <stdio.h>
#include <ctype.h>
int main(void) {
int j;
scanf ("%d",&j);
if (j>=1&&j<=10){
int i=0;
int USER_NAME=100;
char name[j][USER_NAME];
for (i=0;i<j;i++){
scanf ("%s",name[i]);
}
for (i=0;i<j;i++){
if ((i%2)==0){
i++;
}
if ((i%2)!=0){
printf ("%s\n",name[i]);
}
}
}
else (printf ("No additional constrainsts"));
return 0;
}
它一直给我这个错误
./oddecho.c: In function 'main':
./oddecho.c:6:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
6 | scanf ("%d",&j);
| ^~~~~~~~~~~~~~~
./oddecho.c:12:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
12 | scanf ("%s",name[i]);
| ^~~~~~~~~~~~~~~~~~~~
我尝试在第 6 行的 scanf 之前使用 (void),但它仍然不断出现问题。 有人可以帮助为什么这个错误不断弹出? 任何帮助将不胜感激
【问题讨论】: