在VC6.0中写win32控制台程序如下:
以下是关于动态内存分配的简单程序:
#include<iostream>
using namespace std;//int _tmain(int argc, _TCHAR* argv[])
void main()
{
int *p=new int;
*p =10;
cout<<*p<<endl;
delete p;
system("pause");
}
在VS2010中写win32控制台程序如下:
#include"StdAfx.h"
#include<iostream>
using namespace std;
//int _tmain(int argc, _TCHAR* argv[])
void main()
{
int *p=new int;
*p =10;
cout<<*p<<endl;
delete p;
system("pause");
}
区别:VS2010中
---要包含 :#include"StdAfx.h"文件
#include<iostream>---不能写.h