question about viewing output

I am just using visual C++ 2005 express as a base to program simple programs in C++. I have a couple problems with the program. 1, after i compile the program, how do i execute the program so that i can see the output of the program. 2. how can i view that in a different window

Any help would be appreciated. thanks


Answer this question

question about viewing output

  • TheJet

     E_Eric wrote:
    i did what you said and it worked... however, when i enter two numbers, it just exits and does not show the product of the two numbers. any ideas

    To amplify the advice you've already received from Christian Graus, you may find this to be helpful:

    1. When you run your project with F5 (Debug |  Start Debugging) the program only stops for debugger breakpoints and any pauses built into the program (e.g., waiting for input).

    2. You can run your application in a separate console window by using Ctrl+F5 (Debug |  Start Without Debugging) and the window will stay open even if your program exits.  This allows you to see the final results.  Click any key to dismiss the window when you are done examining the results.

    The advantage of the second method is that it does not require you to build a final pause into your program, something you might not want there all of the time. 

    Also, the Ctrl-F5 behavior is very close to what you will get if you execute your program from a command prompt (Tools | Visual Studio 2005 Command Prompt) or (Windows Start | All Programs | Accessories | Command Prompt if you're not in VC++ 2005 Express Edition or Visual Studio 2005).



  • Tom Tilque

    PRessing F5 will compile and run your code. If it's a console program, try setting a breakpoint on the last line, or add code to accept input, such as

    int i = 0;

    cin >> i;

    to force your code to stop and let you view the output.

    What sort of project is it It will run in it's own window, by default, even if it's a console window.



  • Lokesh Jain

    Glad to help. I've marked my answer as correct - could you do that for any correct answers you get in future Only because the forums are searchable, and answers marked as correct will both empty the 'view unanswered questions' filter ( which I use all the time ), and because answers marked as correct are bumped in priority for the search engine.



  • ZAHID HUSSAIN12

    This code will work, but it will exit because there's nothing to stop the program, nothing to make it pause after then numbers are input. Add this line"

    std::cin >> V1;

    before the return 0; line, and it will stop for another input, allowing you to view the result.



  • love_1776

    Thank you...

    Even I had the same problem.

    But when I use ctrl+ f5 is absolutely great.

    Thank You.


  • Sarvesh Gowda

    alright will do
  • CDXX

    thanks cgraus. It worked!

  • DanH71

    here is the code that i am using. It is a basic program that i got from a book

    #include <iostream>
    //: simple program to try out c++//:
    int main()
    {
    std::cout << "enter two numbers:" << std::endl;
    int V1, V2;
    std::cin >> V1 >> V2;
    std::cout << "the sum of " << V1 << "and " << V2 << "is " << V1 + V2 << std::endl;

    return 0;
    }

    i did what you said and it worked... however, when i enter two numbers, it just exits and does not show the product of the two numbers. any ideas

  • question about viewing output