Complete novice at C++

Right basically I know not heads or tails with C++, ive had some expirience with VB but in all honestly that's about the extent of my programming knowledge. I wanted to write a basic "Hello World" program. Did so using a guide online, this is what i wrote:


#include <iostream>
using namespace system;

int main () { cout<< "Hello World"; return 0; }


Not working, obviously otherwise i wouldnt be asking lol, tried fiddling around with it and checking it against other "Hello World" programs, should be working. But yeah id appreciate any help or tips any of you can give me :) thanks
The standard namespace is called std. There's no system namespace in the C++ standard library.
ok. changed it to std. now it's coming up with that it cant locate the HelloWorld.exe file.
IDE? Compiler? Exact error message?
Is there a HelloWorld.exe file in the Debug folder of your project?
right changed it completely:

#include <stdio.h>

int main ()
{
printf("Hello World!\n");

return 0;
}


but now the program window closes down immediatly. not sure why? sorry for changing it btw.
That's C code, not C++.
You should answer the questions.
thanks mate. looked into it and now ive done it. got it all displaying ect. thanks again.
The best way that i've found is by doing this:

#include "stdafx.h"
#include <iostream>

using namespace std;


int main ()
{
cout << "Hello World!\n";
cin.get();
return 0;
}


cin.get() will wait untill it gets a response from the user to continue.
If you want to write a console application, run it from the console. That way you don't have to worry about all these cin.get()'s, cin.ignore()'s, etc...

Find out where the compiler put your executable ("prgm.cpp" becomes "prgm.exe" or "prmg") then open cmd.exe, bash, or (insert whatever shell your OS uses here) and change your working directory to the one where your executable program resides ("cd DIR_NAME" or "chdir DIR_NAME".) Then just type the name of your executable and hit enter.
Topic archived. No new replies allowed.