c++如何传递动态内存
先看一段代码:
#include<iostream>using namespace std;void GetMe(char **p,int num){*p=(char*)malloc(sizeof(char)*num);}int main(){char *str=NULL;GetMe(&str,100);strcpy(str,"Hello!");cout<<str<<endl;delete str;return 0;}