Need Help..My First Hello World App..C++

N_350Z

In Runtime
Messages
205
Okay I decided to try and start some programming in C++, this is my first attempt, and I can't seem to get it. Anyone willing to help?
Whenever I try to compile it, it says 'no newline at end of file' and 'multiple definition of main'..heres the script.

#include <iostream>
// my first adventure into C++

#include <iostream>
using namespace std;

int main ()
{
cout << "You Suck At C++";
return 0;
}
 
you don't need to include the iostream file twice.

you also don't really need to declare the namespace.

take out those two lines and remove the space between main and () then it should work
 
root, yes you do need the namespace. Either that or you need to do std::cout, which gets annoying in a long program.
 
My bad guys, I wasn't doing it right, I was just going File>New>Source Code. Someone told me in an IM to go File>New>Project>Empty Project.

Amazing that it took me an hour and a half to write that and get it compiled properly and all that good stuff.

Thanks for the help.
 
N_350Z said:
My bad guys, I wasn't doing it right, I was just going File>New>Source Code. Someone told me in an IM to go File>New>Project>Empty Project.

That's why you're better compiling tiny programs like that on the command line, TBH. I'd only use a project if you've got more than 10 source files, but that's just my opinion.

I'd go

gcc *.cpp <other arguments you're passing in>

to run every file in the directory with the .cpp file extension through the compiler.
 
Back
Top Bottom