C语言问题一枚
void GetMemory(char **p, int num) {
*p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello");
printf(str);
}
请问运行 Test函数会有什么样的结果?
2012-02-25 15:17
2012-02-25 15:44
2012-02-26 12:45
2012-02-26 12:47
2012-02-26 14:45
程序代码:#include <iostream>
using namespace std;
void GetMemory(char **p, int num)
{
*p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello");
cout<<str<<endl;
}
int main()
{
Test();
return 0;
}以上的输出结果是hello
2012-02-26 16:35
2012-02-26 20:20