69,381
社区成员
发帖
与我相关
我的任务
分享
$ cat u.c
#include <stdio.h>
#include <string.h>
int main()
{
char * p = 100;
unsigned long len = 0;
printf("1\n"); // 加上这样的语句,知道哪里出错了。
len = strlen(p);
printf("2\n");
printf("%c\n", p[0]);
return 0;
}
$ ./u
1
Segmentation fault
size_t __cdecl strlen (
const char * str
)
{
const char *eos = str;
while( *eos++ ) ;
return( (int)(eos - str - 1) );
}