一个小程序,运行出错,帮忙看看。
jzlzk 2003-08-25 03:48:12 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void ss(char *s)
{
char p[10]="abcdefg\0";
strncpy(s,p,strlen(p));
}
void mm()
{
char *s;
ss(s);
printf("%s\n",s);
}
int main()
{
mm();
return 0;
}
运行后:
abcdefg
Segmentation fault