
-----------------------------------
s0opatro0pa
Sun Apr 08, 2007 10:37 am

command prompt always closes in a milisecond...o.o
-----------------------------------
hmm...well the title says it all...im REEEEEEEEEEEAAAAAAAALLLYY noob so it could easily be a stupid mistake [most probably is]
im using Dev-C++ and after i press F9, it pops up command prompt for a milisecond and BOOM gone... Dev doesnt tell me what im doing wrong too

all help is appreciated! =D

-----------------------------------
md
Sun Apr 08, 2007 10:50 am

RE:command prompt always closes in a milisecond...o.o
-----------------------------------
The problem is that after your program runs and finishes the window closes. 

There are two solutions; the bad one is to add a delay to the end of your program (usually by reading some input). The other option is to open a comand promt and run your program from the command line.

-----------------------------------
s0opatro0pa
Sun Apr 08, 2007 11:05 am

Re: command prompt always closes in a milisecond...o.o
-----------------------------------
o thanks! 
but in school, i tried this on c-free and it always gave a "press any button to continue..." at the end of the program. is there anyway that i can do that too?

-----------------------------------
PaulButler
Sun Apr 08, 2007 1:10 pm

RE:command prompt always closes in a milisecond...o.o
-----------------------------------
Add this to the end of main():

[syntax="c++"]
string a;
cout > a;
[/syntax]

I haven't tried it and I am fairly new to c++, so there may be a better way.

-----------------------------------
md
Sun Apr 08, 2007 2:05 pm

RE:command prompt always closes in a milisecond...o.o
-----------------------------------
That would work, assuming you are using namespace std; Generally speaking it's a poor idea to do that though, so it would be std::string, std::cout and std::cin.

-----------------------------------
PaulButler
Sun Apr 08, 2007 2:09 pm

Re: RE:command prompt always closes in a milisecond...o.o
-----------------------------------
That would work, assuming you are using namespace std; Generally speaking it's a poor idea to do that though, so it would be std::string, std::cout and std::cin. 

Thanks, that's good to know. Another reason to love c++ :roll:

-----------------------------------
s0opatro0pa
Sun Apr 08, 2007 4:27 pm

RE:command prompt always closes in a milisecond...o.o
-----------------------------------
umm..lol..not to sound rude, but i REEEEEEEEEEEEAAAAAAAAAAAAAAALLLLLLLLLLLLLYYY meant that i am REEEEEEAALLY newbie, like one or 2 days that i started this so im still on hello world for the most part. i tried hello world with iostream but it says that it doesnt exist =s
i stoped the thing from closing with the #include conio.h and getch ();

oh so yeaa, can anyone tell me why the iostream doesnt exist??

-----------------------------------
md
Sun Apr 08, 2007 5:11 pm

RE:command prompt always closes in a milisecond...o.o
-----------------------------------
Can you post your code? Just include it in [ code][/code] tags.

-----------------------------------
s0opatro0pa
Sun Apr 08, 2007 6:19 pm

Re: command prompt always closes in a milisecond...o.o
-----------------------------------
well this is the new one im working on that says iostream wasnt found and string wasnt found either...


#include 
#include 
#include 
using namespace std;

int main()
{
    string Name, Age;
    
    cout > Name;
    
    Cout 