题目内容

下面的程序各自独立,请问执行下面的四个TestMemory 函数各有什么样的结果?
①void GetMemory(char * p)
{
p = (char * )malloc(100);
}
void TestMemory (void)
{
char *str = NULL;
GetMemory (str);
strcpy(str, "hello world");
prinff(str);
}
② char * GetMemory (void)
{
char p[ ] = "hello world";
return p;
}
void TestMemory (void)
{
char * str = NULL;
str = GetMemory();
printf(str);
}
③void GetMemory(char * * p, int num)
{
* p = (char * )malloc(num);
}
void TestMemory (void)
{
char * str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello" );
printf(sir);
}
④void TestMemory (void)
{
char *str = (char * )malloe(100);
strepy (str, "hello" );
free (str );
if(str ! = NULL)
{
strepy(str, "world" );
printf(str);
}
}

查看答案
更多问题

沉淀池和排水管可否同时进行功能性试验。为什么?

They will go to the ______ and see the new film.

What dine shall we go?

You gather with friends there. eating. drinking and playing.

答案查题题库