Thread: [Dev-C++] why does window close after execution? newbie
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Graham <sai...@bi...> - 2003-08-01 10:45:43
|
I have installed Dev-C under Win XP Pro and am running the traditional "Hello World" as the first exercise in my tutorial. When it is compiled and run it instantly closes the window after printing to the screen. I therefore cant see the output. Is there a way to change this with a setting of DEV-C or will I have to put up with adding some sort of pause statement at the end of everything I write? my code looks like this /* *Hello, "Hello World.\n" */ #include <iostream> int main () { cout<<"Hello, world.\n"; return 0; } regards Graham (on L Plates) |
From: <or...@vp...> - 2003-08-01 11:31:43
|
Graham wrote: > I have installed Dev-C under Win XP Pro > and am running the traditional "Hello World" as the first exercise in my > tutorial. > When it is compiled and run it instantly closes the window after > printing to the screen. I therefore cant see the output. > Is there a way to change this with a setting of DEV-C or will I have to > put up with adding some sort of pause statement at the end of everything > I write? > > my code looks like this > /* > *Hello, "Hello World.\n" > */ > #include <iostream> > int main () > { > cout<<"Hello, world.\n"; > return 0; > } This is indeed a VVVVVFAQ (very-very-very-very-...). BTW this is absolutely NORMAL behaviour. To make the dos-prompt stay, you need to pause your program at the end. Use this line before return: getc(); This will wait for an "Enter". (I don't like system("PAUSE"), as that is platform-dependent). -- Greetings, Balázs |
From: Graham <sai...@bi...> - 2003-08-01 14:09:05
|
woops .. obviously a newbie ... I replied under the wrong subject here it is with right subject header I did look at the FAQ this is where I found the Pause suggestion my question was can I prevent the window closing with a setting in DEV-C When I was learning other languages and using JGrasp for instance it could be set to not close the window so that the output could be viewed. This was not done by code added on the end each time but was done by a setting in JGrasp ... I was hoping it was possible to change a setting in DEV-C to achieve this. I could not find an answer in the FAQ and wondered if anyone here could assist. Please forgive me if this is not the correct forum for such a question. regards Graham ----- Original Message ----- From: "OROSZI Balázs" <or...@vp...> To: <dev...@li...> Sent: Friday, August 01, 2003 9:01 PM Subject: Re: [Dev-C++] why does window close after execution? newbie Graham wrote: > I have installed Dev-C under Win XP Pro > and am running the traditional "Hello World" as the first exercise in my > tutorial. > When it is compiled and run it instantly closes the window after > printing to the screen. I therefore cant see the output. > Is there a way to change this with a setting of DEV-C or will I have to > put up with adding some sort of pause statement at the end of everything > I write? > > my code looks like this > /* > *Hello, "Hello World.\n" > */ > #include <iostream> > int main () > { > cout<<"Hello, world.\n"; > return 0; > } This is indeed a VVVVVFAQ (very-very-very-very-...). BTW this is absolutely NORMAL behaviour. To make the dos-prompt stay, you need to pause your program at the end. Use this line before return: getc(); This will wait for an "Enter". (I don't like system("PAUSE"), as that is platform-dependent). -- Greetings, Balázs ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
From: Richard C. <tel...@ya...> - 2003-08-02 02:08:47
|
heck he's programming for DOS, let him use system("PAUSE").=20 it goes against the very nature of programming to get() or cin or scanf e= tc when you dont want to! i mean, sure it does the trick, but it doesnt 'wait for an 'enter'' it wa= its to read in the next character or string or whatever. i dunno, i'm being pedantic i know. ;) but how many other platform have console windows which open and close lik= e they do in windows?? 1/08/03 9:31:46 PM, OROSZI Bal=E1zs <or...@vp...> wrote: >Graham wrote: > >> I have installed Dev-C under Win XP Pro >> and am running the traditional "Hello World" as the first exercise in = my=20 >> tutorial. >> When it is compiled and run it instantly closes the window after=20 >> printing to the screen. I therefore cant see the output. >> Is there a way to change this with a setting of DEV-C or will I have t= o=20 >> put up with adding some sort of pause statement at the end of everythi= ng=20 >> I write? >> =20 >> my code looks like this >> /* >> *Hello, "Hello World.\n" >> */ >> #include <iostream> >> int main () >> { >> cout<<"Hello, world.\n"; >> return 0; >> } > >This is indeed a VVVVVFAQ (very-very-very-very-...). >BTW this is absolutely NORMAL behaviour. To make the dos-prompt stay,=20 >you need to pause your program at the end. Use this line before return: > >getc(); > >This will wait for an "Enter". >(I don't like system("PAUSE"), as that is platform-dependent). > >-- >Greetings, > Bal=E1zs > > > >------------------------------------------------------- >This SF.Net email sponsored by: Free pre-built ASP.NET sites including >Data Reports, E-commerce, Portals, and Forums are available now. >Download today and enter to win an XBOX or Visual Studio .NET. >http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01= /01 >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Graham <sai...@bi...> - 2003-08-02 02:49:37
|
The debate about which piece of code to use to stop the window from closing is very interesting and educational and I thank all contributors BUT My question is can it be done without adding code. The problem only occurs when I compile and run in DEV-C When I take the work in to uni, they run it on grasp or something else where this problem doesnt occur. SO My Question Is is the not a setting in DEV-C that will make it keep the window open?? eg this is a DEV-C question not a C programming question thanking all for your assistance Graham ----- Original Message ----- From: "Richard Chiu" <tel...@ya...> To: <dev...@li...> Sent: Saturday, August 02, 2003 11:45 AM Subject: Re: [Dev-C++] why does window close after execution? newbie heck he's programming for DOS, let him use system("PAUSE"). it goes against the very nature of programming to get() or cin or scanf etc when you dont want to! i mean, sure it does the trick, but it doesnt 'wait for an 'enter'' it waits to read in the next character or string or whatever. i dunno, i'm being pedantic i know. ;) but how many other platform have console windows which open and close like they do in windows?? 1/08/03 9:31:46 PM, OROSZI Balázs <or...@vp...> wrote: >Graham wrote: > >> I have installed Dev-C under Win XP Pro >> and am running the traditional "Hello World" as the first exercise in my >> tutorial. >> When it is compiled and run it instantly closes the window after >> printing to the screen. I therefore cant see the output. >> Is there a way to change this with a setting of DEV-C or will I have to >> put up with adding some sort of pause statement at the end of everything >> I write? >> >> my code looks like this >> /* >> *Hello, "Hello World.\n" >> */ >> #include <iostream> >> int main () >> { >> cout<<"Hello, world.\n"; >> return 0; >> } > >This is indeed a VVVVVFAQ (very-very-very-very-...). >BTW this is absolutely NORMAL behaviour. To make the dos-prompt stay, >you need to pause your program at the end. Use this line before return: > >getc(); > >This will wait for an "Enter". >(I don't like system("PAUSE"), as that is platform-dependent). > >-- >Greetings, > Balázs > > > >------------------------------------------------------- >This SF.Net email sponsored by: Free pre-built ASP.NET sites including >Data Reports, E-commerce, Portals, and Forums are available now. >Download today and enter to win an XBOX or Visual Studio .NET. >http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > ------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
From: Daniel K. O. <dan...@ya...> - 2003-08-02 03:46:00
|
Graham wrote: >My Question Is >is the not a setting in DEV-C that will make it keep the window open?? >eg this is a DEV-C question not a C programming question > > > 1) Go to Tools menu -> Configure tools 2) Click the Add button 3) Type: Title: Run in a DOS box Program: c:\windows\command.com Working directory: <PROJECTPATH> Parameters: /K <EXENAME> 4) Every time you want to run it, go to Tools -> Run in a DOS box. Daniel K. O. |
From: <or...@vp...> - 2003-08-02 06:54:12
|
Richard Chiu wrote: > heck he's programming for DOS, let him use system("PAUSE"). > it goes against the very nature of programming to get() or cin or scanf etc when you dont want to! > i mean, sure it does the trick, but it doesnt 'wait for an 'enter'' it waits to read in the next character or string or whatever. Yes, but because of buffering, it will only return, when you press an 'enter'. And actually, I was wrong, it is getchar(). -- Greetings, Balázs |