linux memset一个结构体指针段错误
typedefstructtt{intname;intscore;}stu;intmain(){stu*test;memset(test,0x00,sizeof(stu)...
typedef struct tt{
int name;
int score;
}stu;
int main()
{
stu *test;
memset(test, 0x00, sizeof(stu));
return 0;
}
这是代码,GDB调试结果
Breakpoint 1, main () at bug1.c:15
15 memset(test, 0x00, sizeof(stu));
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
memset () at ../sysdeps/i386/i686/memset.S:85
85 ../sysdeps/i386/i686/memset.S: No such file or directory.
in ../sysdeps/i386/i686/memset.S
Current language: auto
The current source language is "auto; currently asm".
linux版本:
Linux book-desktop 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux
其他版本不会出现这种问题啊
没有财富值了T.T,跪求大神解答,谢谢~ 展开
int name;
int score;
}stu;
int main()
{
stu *test;
memset(test, 0x00, sizeof(stu));
return 0;
}
这是代码,GDB调试结果
Breakpoint 1, main () at bug1.c:15
15 memset(test, 0x00, sizeof(stu));
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
memset () at ../sysdeps/i386/i686/memset.S:85
85 ../sysdeps/i386/i686/memset.S: No such file or directory.
in ../sysdeps/i386/i686/memset.S
Current language: auto
The current source language is "auto; currently asm".
linux版本:
Linux book-desktop 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux
其他版本不会出现这种问题啊
没有财富值了T.T,跪求大神解答,谢谢~ 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询