c++指针参数是如何传递内存的

  参数策略 如果函数的参数是一个指针,不要指望用该指针去动态申请内存。如下: void GetMemory(char *p, int num) { p = (char *)malloc(sizeof(char) * num); } void Test(void) { char *str = NULL; GetMemory(str, 100); //str仍未NUL
相关文章
相关标签/搜索