我目前正在阅读的书中编写挑战性问题的代码。我的代码以正确的输出完美执行,但是我在代码中收到警告,我只是想知道为什么。
我在显示以下内容的行上收到警告:
int countdownStart = atoi(numInput);
我收到的警告说:
函数“ atoi”的隐式声明在C99中无效
#import <readline/readline.h>
#import <stdio.h>
int main(int argc, const char * argv[]){
printf("Who is cool? ");
const char *name = readline(NULL);
printf("%s is cool!\n\n", name);
printf("What should I start counting? ");
const char *numInput = readline(NULL);
int countdownStart = atoi(numInput);
for (int i = countdownStart; i >= 0; i--){
if (i % 3 == 0){
printf("%d\n", i);
if (i % 5 == 0){
printf("Found one!\n");
}
}
}
return 0;
}
您必须包含stdlib.h
#include <stdlib.h>
下次遇到类似的警告时,仅运行该命令man atoi
,并且手册页应说明应包含哪个头文件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句