gpt4 book ai didi

c - 我该如何解决我的编译错误以及我应该进行哪些更改以使其改进

转载 作者:行者123 更新时间:2023-11-30 19:28:14 26 4
gpt4 key购买 nike

我的源代码中的编译错误在c:

/image/quF7q.png

请告诉我这个编译错误是什么以及如何解决它以及我可以进行哪些更正

最佳答案

如果我汇总所有评论和更多内容:

#include <stdio.h>

int main()
{
int num;

printf("enter a number less than 10 : ");
if (scanf("%d", &num) != 1)
puts("invalid input");
else if (num < 10)
puts("what an obidient savant you are!");
else
puts("wrong number");

return 0; // may be return an other value on error cases ?
}

示例:

pi@raspberrypi:/tmp $ gcc -pedantic -Wall c.c
pi@raspberrypi:/tmp $ ./a.out
enter a number less than 10 : 1
what an obidient savant you are!
pi@raspberrypi:/tmp $ ./a.out
enter a number less than 10 : z
invalid input
pi@raspberrypi:/tmp $ ./a.out
enter a number less than 10 : 20
wrong number

关于c - 我该如何解决我的编译错误以及我应该进行哪些更改以使其改进,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54388074/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com