Author Topic: Program closes straight after opening  (Read 5656 times)

Analizer

  • Guest
Program closes straight after opening
« on: April 01, 2012, 11:23:35 am »
Hello.

I started learning C++ about 2 or 3 days ago, learning from quite a few books. I created a simple converter from feet to metres.
It works fine in Code Blocks (after pressing F9) but when I find the .exe file in the folder, open it, write the feet amount and when I press Enter it converts but it closes straight after. So the window is only visible for less than half a second.

Any suggestions? 


Code: [Select]
#include <iostream>

using namespace std;

int main()
{
    int     feet ;
    float   meters ;
    float   converter = 0.3048 ;

    cout << "Give the amount in feet: " ;
    cin >> feet ;

    meters = feet * converter ;

    cout << "\n" ;

    // ----- results
    cout << feet << " feet equals to "
         << meters << " meters \n" ;
    cout << " \n\n" ;
}

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 11938
    • Travis build status
Re: Program closes straight after opening
« Reply #1 on: April 01, 2012, 11:32:54 am »
Project -> Properties -> Build targets -> your target -> Pause when execution ends
(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!]