学习中心
登录
已解决
指针笔试题1

void GetMemory( char *p )
{
p = (char *) malloc( 100 );
}
void Test( void )
{
char *str = NULL;
GetMemory( str );
strcpy( str, “hello world” );
printf( str );
}

还是不理解为什么执行GetMemory函数之后str的值不会变,不应该是经过(char *) malloc( 100 )申请了一个堆上的size100的空间并返回这个堆的首地址赋值给str吗

young
2023-03-23 20:04:08
177
1

周智华与学员的交流

回答老师

离线

擅长技术:
向TA提问