|
-
February 19th, 2008, 01:40 PM
#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 << " ";
}
-
February 19th, 2008, 01:46 PM
#2
Re: Execution Issue
You can either run the program from the command line or add a cin.get(); just before return 0; in main().
-
February 19th, 2008, 02:05 PM
#3
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
-
February 19th, 2008, 06:18 PM
#4
Re: Execution Issue
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|