65,213
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <crtdbg.h>
#include <fstream>
#include <iostream>
#include <strstream>
using namespace std ;
int main(int argc, char* argv[])
{
_CrtMemState s01, s02, s03;
_CrtMemCheckpoint( &s01 );
printf("Hello World!\n");
ifstream strm("test.txt",ios::in);
if (!strm)
{
cout<<"Cannot open "<<"test.txt"<<endl;
}
strm.close();
_CrtMemCheckpoint( &s02 );
if ( _CrtMemDifference( &s03, &s01, &s02) )
{
printf("leaking\n");
_CrtMemDumpStatistics( &s03 );
}
else
printf("memory check done!\n");
return 0;
}