64,671
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
//这么写
#include <iostream>
#include <malloc.h>
#include <Tchar.h>
using namespace std;
void main()
{
TCHAR* str=new TCHAR[10];
str[2]='a';
cout<<_msize(str)<<endl;
cout<<str[2]<<endl;
}
//可以用_msize检测下是否真的申请了10个内存空间,比如:
#include <iostream>
#include <malloc.h>
using namespace std;
void main()
{
char* str=new char[10];
str[2]='a';
cout<<_msize(str)<<endl;
}