Author Topic: Programs all close out to fast when I select "Application".  (Read 2259 times)

Offline James1st

  • Single posting newcomer
  • *
  • Posts: 9
Programs all close out to fast when I select "Application".
« on: December 13, 2014, 01:01:25 pm »
Hello,

I have copied a number of short programs from a tutorial.
The programs all run well when I choose, "Build and Run", or just, "Run". The windows appear, the programs run, I can enter and read out data with no problems.

But if I run any and all of the programs by clicking on "Application", the windows close immediately.

I have searched and tried many of the given solutions but none work for me.

Does anyone have any suggestions? I would appreciate them, for sure.

thank you

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Programs all close out to fast when I select "Application".
« Reply #1 on: December 13, 2014, 02:49:45 pm »
OS?

Offline James1st

  • Single posting newcomer
  • *
  • Posts: 9
Re: Programs all close out to fast when I select "Application".
« Reply #2 on: December 13, 2014, 03:59:18 pm »
Dell 17" Inspiron 5721 Laptop
MS Windows 7, Home Premium
x64-based PC



 
« Last Edit: December 13, 2014, 04:13:53 pm by James1st »

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Programs all close out to fast when I select "Application".
« Reply #3 on: December 13, 2014, 06:06:55 pm »
On windows when you launch (by double clicking on it) a console executable, it is executed in a command prompt (cmd.exe) which is automatically terminated when the launched executable ends. Unless you insert some wait routine at the end of your code, you won't be able to see what happens when your program ends. To circumvent this situation you can launch your code in an already open command prompt (I suggest you don't ask how because this type of questions including your original question is against the forum rules as they are not related to CB) or stick to CB's way of doing things or program a GUI application. Hope that clears your question.

Offline James1st

  • Single posting newcomer
  • *
  • Posts: 9
Re: Programs all close out to fast when I select "Application".
« Reply #4 on: December 13, 2014, 08:09:50 pm »
My original question was related to CB. That is the compiler I am running. The little test programs run very well in "run" and in "build and run". They close out too soon when I run them as an application.  I have tried numerous suggestions on ending the programs with "wait" routines. Some work on some programs but not on others.
Okay, I certainly thank you for replying to my question. I do appreciate it. :)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11823
    • Travis build status
Re: Programs all close out to fast when I select "Application".
« Reply #5 on: December 13, 2014, 08:21:04 pm »
Please read this part of our FAQ http://wiki.codeblocks.org/index.php?title=FAQ-General to gain an understanding what CB really is.
The answer by scarphin explains exactly what your problem is. Please re-read his answer once again!

hint: to fix it just put a getchar(); at the end of your programs.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline James1st

  • Single posting newcomer
  • *
  • Posts: 9
Re: Programs all close out to fast when I select "Application".
« Reply #6 on: December 13, 2014, 10:47:24 pm »
Okay, thanks, I see what you mean. Live and learn!:)