Author |
Message |
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Thu Nov 16, 2006 6:35 pm Post subject: probblem with c++ |
|
|
|
|
// my first program in C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
|
when i enter it in c++ it compiles it fine, but when i run it it closes... need help
also all of other stuf that i compile doesnt work like
// my second program using variables
#include <iostream>
using namespace std;
int main ()
{
//telling variables
int a,b;
int result;
//variable values and process
a = 5;
b = 2;
a = a + 1;
result = a - b;
//show the result
cout<< result;
//turn off the program function
return 0;
}
|
|
|
Back to top |
|
|
BDwinsAlt Agurus's Posse
Age:33 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Thu Nov 16, 2006 7:24 pm Post subject: |
|
|
|
|
is it only my computer that does that? because last year when i started c++ i dint need the pause function.. |
|
Back to top |
|
|
BDwinsAlt Agurus's Posse
Age:33 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Thu Nov 16, 2006 7:26 pm Post subject: |
|
|
|
|
I'm pretty sure it depends on the compiler. With Dev C++ I had to, with Visual Studio .NET 2003 I don't have to. |
|
Back to top |
|
|
Muskrat Server Help Squatter
Age:37 Joined: Aug 24 2004 Posts: 829 Location: Swamp Offline
|
Posted: Thu Nov 16, 2006 9:27 pm Post subject: |
|
|
|
|
ya know if you ran it from a command line it wouldn't disappear, that's why it dosent close in visual studio either.... |
|
Back to top |
|
|
BDwinsAlt Agurus's Posse
Age:33 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Thu Nov 16, 2006 9:32 pm Post subject: |
|
|
|
|
For some reason people like to just click on icons. Just use a simple batch file in that case to execute it. |
|
Back to top |
|
|
Muskrat Server Help Squatter
Age:37 Joined: Aug 24 2004 Posts: 829 Location: Swamp Offline
|
Posted: Thu Nov 16, 2006 10:46 pm Post subject: |
|
|
|
|
Or he could write programs which either A. don't need input or output in a command line or B. has an input loop that will not end the program until he tells it to. |
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Nov 17, 2006 12:31 pm Post subject: |
|
|
|
|
System commands suck. If you really want to wait for an enter key at the end or something, use cin.getc() or whatever it's called. (The getchar() equivalent.) You might want to call cin.flush() beforehand, too, to make sure it has to prompt for input. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
|
|