Author Topic: How to save as .exe ?  (Read 3752 times)

Yamraj-

  • Guest
How to save as .exe ?
« on: September 07, 2012, 04:49:55 pm »
Hi guys, As you may figure, this is my first post on the forums, and it has only been one day since I have started learning C++. While exploring the language, I made this VERY basic program.

This is the code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <iostream>

using namespace std;

int main()
{
    string m;
    int first;
    int second;
    int answer;
    int third;
    cout << "This is the automatic multiplier. Please follow the instructions." << endl;
    cout << "Type in \"Yes\" to Continue." << endl;
    cin >> m;
    cout << "Enter your First number to multiply." << endl;
    cin >> first;
    cout << "Enter the Second number." << endl;
    cin >> second;
    cout << "Enter the Third number." << endl;
    cin >> third;
    answer = first*second*third;
    cout << "Your answer is " << answer;

    return 0;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When I run the program inside of Code::Blocks, it runs flawlessly, but when I go to the program's directory and open the .exe from the Debug folder, I can insert all the numbers, but when the answer is supposed to come, the program closes right away.

Can someone please tell me if I'm doing something wrong, or if there is a seperate way to save the code as an .exe?

Thanks in Advance!  ;D

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to save as .exe ?
« Reply #1 on: September 07, 2012, 04:53:01 pm »
Run it from a console/cmd window. Or put a pause command at the end. But this is not a topic you can discuss here. Search for site dedicated to teaching/helping to novice programmers.
(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!]