#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
const char *str = "123are you ok";
char *endp;
long int result;
result = strtol (str, &endp, 0);
printf ("%d\n", result);
printf ("str 字符串起始地址 0x%p\n", str);
printf ("endp 指向的地址为 0x%p\n", endp);
return (0);
}
./strtol
123
str 字符串起始地址 0x0x80485a0
endp 指向的地址为 0x0x80485a3
./strtol
123456
str 字符串起始地址 0x0x80485c0
endp 指向的地址为 0x0x80485c6
*endp 的值为 0
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |