News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Program closes straight after opening

Started by Analizer, April 01, 2012, 11:23:35 AM

Previous topic - Next topic

Analizer

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? 


#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" ;
}

oBFusCATed

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!]