标签:
应用实例:
#include <stdlib.h> #include <stdio.h> int main() { long c = 0; char *endptr; c = strtoul("200e-2",&endptr,10); printf("原始字符串:200e-2\t转换后:%d\t返回字符串:%s\n",c,endptr); c = strtoul("-123%^456",&endptr,10); printf("原始字符串:-123%^456\t转换后:%d\t返回字符串:%s\n",c,endptr); c = strtoul("#$%123%^098",&endptr,10); printf("原始字符串:#$%123%^098\t转换后:%d\t返回字符串:%s\n",c,endptr); c = strtoul(" ",&endptr,2); printf("原始字符串: \t转换后:%d\t返回字符串:%s\n",c,endptr); c = strtoul("0.55",&endptr,10); printf("原始字符串:0.55\t转换后:%d\t返回字符串:%s\n",c,endptr); c = strtoul("-145789632",&endptr,10); printf("原始字符串:-145789632\t转换后:%d\t返回字符串:%s\n",c,endptr); c = strtoul("$#@!",&endptr,10); printf("原始字符串:$#@!\t转换后:%d\t返回字符串:%s\n",c,endptr); return 0; }运行结果:
标签:
原文地址:http://blog.csdn.net/kongshuai19900505/article/details/51884429