CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Execution Issue

  1. #1
    Join Date
    Feb 2008
    Posts
    1

    Execution Issue

    I am new to writing code.

    That being said, I run the *.exe and it executes however there is no output

    I have the code copied line for line, I've triple checked and had a friend who writes code for a living check. It compiles, no errors found.....

    But no output either.

    I think I may have had this issue with the compiler before, but don't remember. I am using dev-c++ 4.9.9.2

    Code:
    /* demonstating paraments */
    
    #include <iostream>
    using namespace std;
    
    void mul(int x, int y); //mul prototype
    
    int main()
    {
        mul(10, 20); //calling mul function
        mul(5, 10);
        mul(23, 72);
        
        return 0;
    }
    
    void mul(int x, int y)
    {
         cout << x * y << " ";
         }

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: Execution Issue

    You can either run the program from the command line or add a cin.get(); just before return 0; in main().
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Aug 2005
    Location
    LI, NY
    Posts
    576

    Re: Execution Issue

    Usually when debugging a console application on Windows I set a breakpoint at the closing brace of main to keep the console open. Additionally, in Visual Studio there is a "Run Without Debugging" option that keeps the console open after the program terminates, which allows you to see the output of destructors called after main returns... Dev-C++ may have something similar.

    The problem with cin.get() at the end of main is that it's often done out of naivety and left in release builds. This is bad behavior for console applications in that it makes them more difficult to automate.
    - Alon

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Execution Issue

    Quote Originally Posted by Hermit
    The problem with cin.get() at the end of main is that it's often done out of naivety and left in release builds. This is bad behavior for console applications in that it makes them more difficult to automate.
    Which is why the proper way of testing a console application is to open a console, and run the executable there.

    Viggy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured