Hello world start program trouble

Hi all! I having some trouble with starting my first console program.
Enyone know what can be?
http://www.fotolink.su/v.php?id=0b9ea31967e402a7526cbd44d1683b74
Wow, I don't know it can be compiled succefully

I would write it like this
1
2
3
4
5
6
7
8
9
#include <iostream>

using namespace std;

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


If I remember corectlly, This problem only occur to me when the program that was going to be compiled is running from somewhere,
closed account (jwkNwA7f)
@rmxhaha
I had the same idea that it was running somewhere else, but it is not in the taskbar and I don't see any other apps that could be running it either.
closed account (3qX21hU5)
agarkov you almost had it right just missed one minor thing.

You forgot the opening and closing brackets { } in your main function.

So instead of

1
2
3
4
5
#include <iostream>
using namespace std;
int main()
    cout << "Hi World!" ;
return 0;


It would be

1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

int main()
{                                    // <---- Notice the opening bracket
    cout << "Hi world!";
    return 0;                    // <---- Also make sure to keep things indented neatly
}                                   // <--- Closing bracket 


Once you get farther along (Mainly when you learn about different scopes and functions) the opening and closing brackets (Code blocks) will make more sense to you.
Don't forget to #include "stdafx.h" for Visual Studio.
Last edited on
closed account (3qX21hU5)
He doesn't need to include that and since he is just beginning with the hello world application it probably would just confuse things even more so there is no need to include it specially since it is VS only.
Last edited on
closed account (jwkNwA7f)
@Zereo
Yes, but, VS typically won't compile unless you include. You can turn off precompiled headers.
same error
closed account (3qX21hU5)
Post the error message a d what your code is please.
This is probably unrelated but perhaps you should check

I had this problem on every compile
that the program run, then the window close but the process doesn't
I have to taskkill the program and delete them everytime I want to compile,

Then I realize there "Sality" in my laptop, After I format and re install everything, everything back to normal

Try running the compiled executable manually ( by double clicking it from window explorer )

Does it run ?

Then try deleting the exe and recompile
Just use a better compiler
(BUT PLEASE DON'T ATTACK ME WITH YOUR POSTS)
Topic archived. No new replies allowed.