Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Sep 16th, 2005, 9:50 AM   #1
tony
Newbie
 
Join Date: Sep 2005
Posts: 2
Rep Power: 0 tony is on a distinguished road
C++ Question

I have posted a simple question about the C++ hello world source code on...

http://www.wikicode.frihost.net/inde...us:Hello_world

Would someone take the time to answer? If you would like, you may simply answer directly on the wiki. Thanks!
__________________
Wikicode: Open-source Code
tony is offline   Reply With Quote
Old Sep 16th, 2005, 9:57 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
I don't think Wikicode's designed for questions. Now, as to your question: take a look at http://www.programmingforums.org/for...7&postcount=49.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 16th, 2005, 10:19 AM   #3
tony
Newbie
 
Join Date: Sep 2005
Posts: 2
Rep Power: 0 tony is on a distinguished road
Thank you, Ooble. Do you then recommend "using namespace std" or "std::"? Also, I run wikicode and the discussion pages like the one I sent you are made for people to add their own comments. Everyone is welcome to edit the site.
__________________
Wikicode: Open-source Code
tony is offline   Reply With Quote
Old Sep 16th, 2005, 10:24 AM   #4
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
I don't have an account on wiki, and am not inclined to set one up just to answer a single question.

However;

1) <iostream.h> is not standard C++. Use <iostream> instead. This will require a "using namespace std;" or rename cout to std::cout and endl to std::endl.

2) In C++, <stdio.h> is allowed, but it's use is discouraged (actually deprecated in the C++ standard). It is probably better to use <cstdio> This will require a "using namespace std;" or rename getchar() to std::getchar().

3) Mixing C and C++ style I/O is not a good idea, particularly with standard devices (stdin/cin and stdout/cout), as they are not required to play nicely together. In practice, they often do, but it is a good idea to use either all C I/O or all C++ I/O --- particularly with standard input and output devices. In the C library, use of getchar() is guaranteed to flush output to stdout. Similarly, in C++, reading from std::cin is guaranteed to flush data to std::cout. However, use of getchar() is NOT guaranteed to flush output to std::cout, and reading from std::cin is not guaranteed to flush output to stdout.

4) Unless you like displaying your ignorance of both C and C++, main() should return int. void main() is not guaranteed to work with all compilers.
grumpy is offline   Reply With Quote
Old Sep 16th, 2005, 5:52 PM   #5
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
it looks like your question was answered and yeah, don't ask people to sign up for a site in your sig because it's not the more "simple" method as you put it. in short what you want is this:

#include <iostream>
using namespace std;

int main()
{
    cout<<"hello world!"<<endl;

    return 0;
}
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja 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 9:29 PM.

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