C++ 中内存分配和回收

void Allocate(char* &p,int size) {
	p = (char*)malloc(size);
}

void Test(void) {
	char *str = NULL;
	Allocate(str,100);
	strcpy(str,"Hello World!");
	printf(str);
	free(str);
}

posted on 2013-07-16 09:51  Yours风之恋  阅读(208)  评论(0编辑  收藏  举报