![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2005
Posts: 2
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Sep 2005
Posts: 2
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
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. |
|
|
|
|
|
#5 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|