|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Lest we forget
Join Date: Jun 2003
Location: Ontario, Canada
Posts: 1,870
|
dev-C++, keep programs open
I want to learn c++ and since dev-c++ was recomended by a couple of web sites I downloaded it. The problem is that when I make console apps they close too fast. How do I keep them open after they finished executing the code?
__________________
redqueen: Antec Sonata, Pentium-D 2.5GHz, MSI G31M3-L, 2GB ram, 320 GB HDD, OpenBSD hal9000: Lenovo T61, 2GB ram, 120 GB HDD, FreeBSD |
|
|
|
|
|
#2 |
|
Professional gadfly
|
Put this line at the end of the main function code block (before the closing }):
system("PAUSE"); That will require you to hit a key before proceeding. |
|
|
|
|
|
#3 |
|
Lest we forget
Join Date: Jun 2003
Location: Ontario, Canada
Posts: 1,870
|
now it gives me:
7 untitled1.cpp implicit declaration of function `int system(...)' |
|
|
|
|
|
#4 |
|
Professional gadfly
|
You will need to put the following include statement at the beginning then:
#include <stdlib.h> As a pointer, if you go to File...New...Project, and then select "Console Application," it will do this automatically for you. I should add that the system statement needs to go before any return statement, if there is one. |
|
|
|
|
|
#5 |
|
Lest we forget
Join Date: Jun 2003
Location: Ontario, Canada
Posts: 1,870
|
Works now, thanks. But it puts #include < stdio.h > automaticly, not #include < stdlib.h >
|
|
|
|
|
|
#6 |
|
Lest we forget
Join Date: Jun 2003
Location: Ontario, Canada
Posts: 1,870
|
Dont wanna start a new thread just for this. How do I make stuff go on the next line? I made a program and its all in 3 lines when it should be in 10.
oh, devC++ is set to put #include < iostream.h > #include < stdlib.h > int main() { system("PAUSE"); return 0; } when it make a new project but instead it puts #include < stdio.h > int main(int argc, char *argv[]) { return 0; } |
|
|
|
|
|
#7 |
|
Professional gadfly
|
To add a carriage return, use endl:
cout<<"This is on one line"<<endl; cout<<"This is on the next line"<<endl; Edit: Fixed brackets. Last edited by doctorgonzo; 04-30-2004 at 06:28 PM. |
|
|
|
|
|
#8 |
|
Lest we forget
Join Date: Jun 2003
Location: Ontario, Canada
Posts: 1,870
|
thanks again!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|