VC++ is alien code

Why a standard hello world:

#include<iostream>

int main(){

cout << "HELLO" << endl;

system("pause")
return (0);

}

can't work on visual c++ 2010 express?

this works also:

1
2
3
4
5
6
7
8
9
  #include <iostream>

int main(){
	std::cout << "Hello World" << std::endl;
	std::cin.get();
	return 0;
}

what are you on about? that first untagged code doesn't even compile?
and use a more sensible thread topic.
closed account (Dy7SLyTq)
of course the non [code ] wont compile. it needs using namespace std
Don't pause programs at the end, run them from the command line.

The top code doesn't compile because cout and endl are in the std namespace ( note "std::" in the second code).

closed account (Dy7SLyTq)
its ok to pause at the end. it wont make a difference
closed account (3qX21hU5)
It does when you use system calls. But generally you should run them from the command line like Lowest said or at least get a IDE that has a option to keep the console open after the program finishes.
Last edited on
closed account (Dy7SLyTq)
ok yes you shouldnt use system but i was talking about c++ code not exes to do it (i know; i should have specified)
using namespace std;


then it works.


THANKYOU
Topic archived. No new replies allowed.