Iris_tang
汤儿
2017-10-08 01:53

PTA上的错误分析,求大神指点(#>д<)ノ

  • 函数

求解求解:

最近在PTA上刷题,先从简单的开始吧。。写一道题时在DEV上编译没什么问题,但是在PTA上提交之后说编译有错误,不知道怎么回事。
代码如下:

#include
void printfN(int N);
int main()
{
int N;
printf("Inpute an positive number:");
scanf("%d",&N);
printfN(N);
return 0;
}
void printfN(int N)
{
if(N<1)
printf("Ivalid Input!\n");
else
{
for(int i=1;i<=N;i++)
printf("%d\n",i);
}

}

错误如是说:
a.c:16:5: error: redefinition of 'main'
int main()
^
a.c:4:5: note: previous definition of 'main' was here
int main ()
^
a.c: In function 'main':
a.c:8:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
a.c: In function 'main':
a.c:20:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&N);
^

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答

为你推荐

换一换