#include<stdio.h> //#include<stdlib.h> int main() { int i; double f; char b[5] = "23"; char c[5] = "2.3"; i = atoi(b); f = atof(c); printf("i=%d f=%lf/n", i, f); return 0; }
gcc test.c -o test没有任何警告 gcc -Wall test.c -o test 出现警告:w9.c: In function `main': w9.c:9: warning: implicit declaration of function `atoi' w9.c:10: warning: implicit declaration of function `atof' 输出结果: i=23 f=1717986918.000000 加上#include<stdlib.h>则结果正常 看来atoi和atof都在C标准库glibc中,但是很奇怪为什么C标准库函数sqrt和pow却不在glibc中