#include <stdlib.h> int atoi(const char *nptr);
[/table]
举例:
include <stdio.h> #include <stdlib.h> int main(int arvc, char **argv) { printf ("%d
", atoi(argv[1]));return (0); }
[table=100%,#f9f7ed]运行输出: # ./atoi 123
123
如果 argv[1] 指定为 123abc ,那么仍然可以正确转换 123 ,即自动忽略掉后面的 abc ,但不能指定 abc123efg 这样的形式,即转换字符串的开始字符一定要是数字形式的。
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2