IDE: Visual Studio 2008
Project Type: Console Application
Point 1:the first program is "Hello world" for a new language
Traditionally, the first program programmers write in a new language is the infamous , and we aren’t going to deprive you of that experience! You’ll thank us later. Maybe.The fact is very funny! The code is following:
#include "stdafx.h"#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ cout <<"Hello World!" <
Point 2: about "stdafx.h"
Important note to Visual Studio users: Visual studio programs should ALWAYS begin with the following line:
#include "stdafx.h"
Otherwise you will receive a compiler warning, such as c:\test\test.cpp(21) : fatal error C1010: unexpected end of file while looking for precompiled header directive.
Alternately, you can turn off precompiled headers. However, using precompiled headers will make your program compile much faster, so we recommend leaving them on
unless you are developing a cross-platform program.
Point 3: about "iostream.h"
This header file privide the input/output methods for console programming:
input:cin
output:cout
for example:
#include "stdafx.h"#includeusing namespace std;int _tmain(int argc, _TCHAR* argv[]){ int x = 0; cout <<"Enter one integer:"; cin >> x; cout <<"The integer you entered is:" << x << endl; return 0;}