View previous topic :: View next topic |
Author |
Message |
C-Dizzle Grandmaster Cheater Reputation: 89
Joined: 16 Mar 2008 Posts: 623
|
Posted: Thu Mar 18, 2010 12:12 pm Post subject: Hello world execution problems |
|
|
So I am just recently starting to learn C++. The problem I am having (Probably nooby) Is that when I click execute it just flashes on screen then disappears.
Sorry if this is a noob question, but thanks in advanced.
|
|
Back to top |
|
|
Slugsnack Grandmaster Cheater Supreme Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Mar 18, 2010 12:23 pm Post subject: |
|
|
make it wait for input at the end with cin or whatever
|
|
Back to top |
|
|
C-Dizzle Grandmaster Cheater Reputation: 89
Joined: 16 Mar 2008 Posts: 623
|
Posted: Thu Mar 18, 2010 12:43 pm Post subject: |
|
|
Here is the code
Code: | // my first program in C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
} |
|
|
Back to top |
|
|
Aqua Regia Advanced Cheater Reputation: 0
Joined: 12 May 2009 Posts: 51 Location: Sweden
|
Posted: Thu Mar 18, 2010 12:58 pm Post subject: |
|
|
I don't think this is very good.. (because it only works for windows or something like that), but I always do like this:
Code: |
#include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
cout << "Hello World!";
getch();
return 0;
}
|
|
|
Back to top |
|
|
C-Dizzle Grandmaster Cheater Reputation: 89
Joined: 16 Mar 2008 Posts: 623
|
Posted: Thu Mar 18, 2010 1:10 pm Post subject: |
|
|
Aqua Regia wrote: | I don't think this is very good.. (because it only works for windows or something like that), but I always do like this:
Code: |
#include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
cout << "Hello World!";
getch();
return 0;
}
|
|
Thank you! This is much better.
|
|
Back to top |
|
|
iPromise Grandmaster Cheater Reputation: -1
Joined: 27 Jun 2009 Posts: 529 Location: Canada
|
Posted: Thu Mar 18, 2010 4:07 pm Post subject: |
|
|
Code: | #include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
system("PAUSE");
return 0;
}
|
|
|
Back to top |
|
|
AtheistCrusader Grandmaster Cheater Reputation: 6
Joined: 23 Sep 2006 Posts: 681
|
Posted: Thu Mar 18, 2010 4:19 pm Post subject: |
|
|
iPromise wrote: | Code: | #include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
system("PAUSE");
return 0;
}
|
|
You don't actually need a return 0...
|
|
Back to top |
|
|
Slugsnack Grandmaster Cheater Supreme Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Thu Mar 18, 2010 4:53 pm Post subject: |
|
|
_visiON_ wrote: | iPromise wrote: | Code: | #include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
system("PAUSE");
return 0;
}
|
|
You don't actually need a return 0... |
actually, for once, iPromise has the right code. although admittedly that is more likely because it was a copy from someone's post above rather than a display of competence
http://users.aber.ac.uk/auj/voidmain.shtml
|
|
Back to top |
|
|
hcavolsdsadgadsg I'm a spammer Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Thu Mar 18, 2010 5:10 pm Post subject: |
|
|
_visiON_ wrote: | iPromise wrote: | Code: | #include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
system("PAUSE");
return 0;
}
|
|
You don't actually need a return 0... |
the standard dictates it so.
ps system() calls are ew, try to avoid them
|
|
Back to top |
|
|
Jani Grandmaster Cheater Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Fri Mar 19, 2010 5:28 am Post subject: |
|
|
slovach wrote: | ps system() calls are ew, try to avoid them |
Code: | #include <cstdlib>
int main(int argc, char *argv[])
{
system("ECHO Hello World!");
system("ECHO Even random number generation works, so what's the problem?");
system("ECHO There are %RANDOM% reasons not to use system()");
system("ECHO Bye!");
system("PAUSE");
return 0;
} | What do ya mean? :P
|
|
Back to top |
|
|
|