Opens and Closes

I need help with this code. I am a beginner programmer and do not know what is wrong with it. After I open the compiled file (It is an .exe file right?) a command prompt window opens then closes.
Here is the code.
Is there anything wrong with it?

#include <iostream>

// Start of Program
int main(int a, int b)
{
a = 5 ;
b = 3 ;
printf ("This is a test run application \n");
printf ("Using integers A and B \n");
if (a > b) {
printf ("Integer A is greater than integer B");
return a;
}
if (b > a) {
printf ("Integer B is greater than or equal to integer B");
return b;
}

}
// End of Program
1. main() can either take no arguments, or take (int argc,char **argv) (the names don't matter, of course). What you're doing there is completely illegal.
Corrected form:
1
2
3
int main(){
    int a,b;
    a=//... 

2. main()'s return value is used to pass signals to the system such as "the program succeeded" or "the program failed". When you don't need to pass something like this, just return zero. What you did is not not wrong, but it's not necessary. Also note that not all paths return a value. What if a==b? Of course, the variables have constant values, but still.
Last edited on
Ok, did that. Do I put a=//5 or just a = 5;?

Also. When I open the compiled file, it just automatically closes.
The //... is intended to convey that the rest is fine as it is.

For your other question, see http://www.cplusplus.com/forum/beginner/1988/
Alright thanks!
Topic archived. No new replies allowed.