What is the output of the main function? Can you explain why
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/16 20:10:02
What is the output of the main function? Can you explain why?
char *GetMemory(void)
{
char p[] = “hello world”;
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);}
char *GetMemory(void)
{
char p[] = “hello world”;
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);}
程序中有点小问题.
结果是乱码.
因为数组存放在栈中,随着函数GetMemory执行完成,栈空间已经释放,被用作其他用途.当指针str指向已释放的数组时,其内容不确定,所以乱码
结果是乱码.
因为数组存放在栈中,随着函数GetMemory执行完成,栈空间已经释放,被用作其他用途.当指针str指向已释放的数组时,其内容不确定,所以乱码
What is the output of the main function? Can you explain why
What is the function of NADH?
What is the function of menu?
What is the basic function of paging
what is the function of music
what is the mean of function ?
Can you explain the reason why you were late?Can you explain
can you explain the disappearance of dinosaurs by the fossil
what is the social function of the language
what is the function of the first paragraph什么意思
what is the function of [peptidoglycan of a eubacteria]
what is the end behavior of this polynomial function,sketch