Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 18th, 2004, 9:36 AM   #1
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Hey,

i havn't programmed in c++ for a while so last night i desided to just fool around for a while. First i just started making a simple hello world programm to get back in the swing of things. Here's the code...just wait i am getting to the question bare with me.

#include <iostream>

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

Anyways, it looks alright....right? When i try to compile it useing the command:
Quote:

gcc -o Hey hello.C
it gives me this error:
Quote:

hello.C: In function `int main()':
hello.C:5: `cout' undeclared (first use this function)
hello.C:5: (Each undeclared identifier is reported only once for each function
it appears in.)
hello.C:5: `endl' undeclared (first use this function)
It just doesn't make any sence to me. I even went back to my old books and searched the net and everything i've read says iostream is good to go. I even looked in my iostream file in the c++ include dir and everything looks fine. I am running Slackware 9.1 if that is any help. Can somebody tell me what the hell is happening. Yes, i know the error could be caused by my lack of memory reguarding c++, since i havn't programmed in c++ in around three years...sad isn't it? Thanks for the help in advance.

-Pizentios
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old May 18th, 2004, 9:52 AM   #2
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,630
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
the problem that i am seeing is that you are trying to compile a c program but you are writing a c++ program you woudlnt use gcc you would use something else i cant think of it off the top of my head if i come up with it later i will post it. and another thing you mite want to save the file as .cpp that mite help you out there too.

edit. well i think the command for compiling a c++ program would be g++ but im not sure i didnt run the command to check but try that out and see what you get good luck
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old May 18th, 2004, 10:25 AM   #3
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Hey,

I tryed the command:

Quote:

g++ -o Hey hello.C
and got the same error. So i mv'd the file to hello.cpp and tryed the g++ command again. Same results. This is confusing...but i guess that's what i guess for forgetting how to programm in c++. Thanks for your help so far.

-Pizentios
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old May 18th, 2004, 12:08 PM   #4
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,630
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
well i got it to work by adding a bit of code all i added was this
using namespace std;
im not sure what it does cause i dont know c++ but it made the program work and compile
so this is the code you would have
#include <iostream>
using namespace std;

int main()
{
    cout << "Hello World" << endl;
    return 0;
}
and then run
g++ -o test test.cpp
those are what i called the file good luck
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old May 18th, 2004, 12:10 PM   #5
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Thanks for the help. I don't ever remember using that in c++. oh, well it works so i an't going to complain. Thanks once again.

-Pizentios
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old May 18th, 2004, 12:14 PM   #6
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,630
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
no problem i love to help.

even when i dont know the language
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old May 18th, 2004, 4:27 PM   #7
lordnothing
Newbie
 
Join Date: Apr 2004
Location: ~/
Posts: 8
Rep Power: 0 lordnothing is on a distinguished road
Send a message via AIM to lordnothing Send a message via MSN to lordnothing
the "using namespace std;" line is part of the C++ standard... the old way is still seen, but very much deprecated... you should pick up a book on standard C++ just to get up to speed on what they've adopted/changed/added to C++ during the standardization process.
__________________
int main{
int count;
for(count=0;count&lt;99;count++){
printf(&quot;I will not throw paper airplanes.\n&quot;);}
}
lordnothing is offline   Reply With Quote
Old May 18th, 2004, 4:59 PM   #8
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
cool, i didn't know that. thanks for the info. know any good sites with this info on them? Just so i don't have to spend money.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old May 20th, 2004, 6:41 PM   #9
lordnothing
Newbie
 
Join Date: Apr 2004
Location: ~/
Posts: 8
Rep Power: 0 lordnothing is on a distinguished road
Send a message via AIM to lordnothing Send a message via MSN to lordnothing
not off the top of my head... i got that from Herbert Schildt's "Teach Yourself C++"
__________________
int main{
int count;
for(count=0;count&lt;99;count++){
printf(&quot;I will not throw paper airplanes.\n&quot;);}
}
lordnothing is offline   Reply With Quote
Old Jun 14th, 2004, 6:04 AM   #10
Stormhawk
Newbie
 
Join Date: Jun 2004
Location: Nottingham, England, UK
Posts: 2
Rep Power: 0 Stormhawk is on a distinguished road
I'd recommend Bjarne Stroustrup's "The C++ Programming Language, 3rd Edition" for an in-depth, up-to-date and comprehensive guide to C++. I used it both to learn the advanced features (I already knew the basics of C++ before buying that book) and as a reference to any part of the language you care to mention. It contains a few chapters on the STL containers and algorithms, with a more indepth look at strings and streams. In all, a very useful book.

http://www.amazon.com/exec/obidos/tg/detai...=glance&s=books
__________________
Andrew J. Bennieston
Founder, http://www.bytekill.net
Stormhawk is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:07 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC