#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中