Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 07-12-2006, 03:22 AM   #1
In Runtime
 
N_350Z's Avatar
 
Join Date: Jul 2006
Posts: 205
Default Need Help..My First Hello World App..C++

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;
}
__________________

N_350Z is offline   Reply With Quote
Old 07-12-2006, 05:10 AM   #2
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,007
Default Re: Need Help..My First Hello World App..C++

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
__________________

__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 07-12-2006, 03:36 PM   #3
Fully Optimized
 
rakedog's Avatar
 
Join Date: May 2004
Posts: 2,718
Send a message via AIM to rakedog
Default Re: Need Help..My First Hello World App..C++

root, yes you do need the namespace. Either that or you need to do std::cout, which gets annoying in a long program.
__________________
hackthissite.org (criticalsecurity.net) | gentoo.org

The best argument against evolution are creationists themselves. They prove that life is devolving rather than evolving.
rakedog is offline   Reply With Quote
Old 07-12-2006, 04:50 PM   #4
Site Team
 
David Lindon's Avatar
 
Join Date: Dec 2002
Posts: 15,233
Default Re: Need Help..My First Hello World App..C++

I just tried compiling your code and it went through fine, what compiler are you using?
David Lindon is offline   Reply With Quote
Old 07-16-2006, 01:21 PM   #5
In Runtime
 
N_350Z's Avatar
 
Join Date: Jul 2006
Posts: 205
Default Re: Need Help..My First Hello World App..C++

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 is offline   Reply With Quote
Old 07-16-2006, 02:19 PM   #6
Fully Optimized
 
UK31337's Avatar
 
Join Date: Feb 2005
Posts: 2,776
Default Re: Need Help..My First Hello World App..C++

Quote:
Originally Posted by N_350Z
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.
__________________

UK31337 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 08:07 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0