返回类型为指针的函数里面动态分配的指针怎么释放
// testpoint.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <malloc.h>
#include <iostream>
using namespace std;
char* test()
{
char* mmm = (char*)malloc(100);
mmm = "sflajdfsda";
return mmm;
//mmm怎么free呢?
}
int _tmain(int argc, _TCHAR* argv[])
{
char* tt = test(); //这里的tt需要free吗?
cout << *tt << endl; //这里只输出了s 怎么输出全部字符串呢?
cin.get();
//free(tt);
//free(mmm);
return 0;
}