I have posted a question about the C++ hello world source code on...
http://www.wikicode.frihost.net/index.php?title=Talk:C_Plus_Plus:Hello_world
Would someone take the time to answer? If you would like, you may simply answer directly on the wiki.
Very good code, thank you very much for your sharing .
main() function should (?) return value.
| Code: |
#include <iostream.h>
#include <stdio.h>
void main() {
cout << "Hello World!\nPress ENTER to continue..." << endl;
getchar ();
return 0;
}
|
The main-function should indeed have a return-value. And the way headers are included is the c-way, not the c++way.
But check my respons at the discussion for more information
| BlackSkad wrote: |
| The main-function should indeed have a return-value... |
The main function must return an int value.
Also it must be declared as int instead of void.
| Code: |
int main() {
// insert your code here
return 0;
}
|
Actually you only return a int if it is int main.And you need to put cin.get(); or something like that to keep the window from closing.
I am not sure what is your question, but here is the actual C++ code for Hello World program:
| Code: |
#include <iostream.h>
int main()
{
cout << "Hello World!\n";
cout << "Press ENTER to continue..." << endl;
getch ();
return 0;
}
|
Whats getch(); for? I don't think its required cause I don't need that.
The getch(); isn't required, but if you leave it, the black screen will pop-up for less the a second and will disappear again. In this way, the window remains open.
You can also achieve this by using 'system("PAUSE");' from the c-lib stdlib (You don't have to cout the sentence "Press blabla..." by using this).
BlackSkad
Can i C++ Become for free.
P.S: Sory for my bad English
| eldarc wrote: |
Can i C++ Become for free.
P.S: Sory for my bad English |
yes 
And the link for the free C++ is:

mabybe this link to google can help you:
Free c++ compiler
The second link is a good one, I tried it myself for a while, but I stopped learning c++ at the moment. I'm thinking in java now
See it yourself and maybe check some other links...
BlackSkad[/url]
| BlackSkad wrote: |
mabybe this link to google can help you:
Free c++ compiler
The second link is a good one, I tried it myself for a while, but I stopped learning c++ at the moment. I'm thinking in java now
See it yourself and maybe check some other links...
BlackSkad[/url] |
gah - why are you thinking in java?