You should note that one does not include function declarations and definitions inside of main! What you're doing now is just that; your bracket finishing main is at the end of the entire program! Usually programmers write additional functions like this:
Code:
int main(void) {
//Do some stuff, add things, subtract others, etc:
int a1, a2;
a1 = function1(5, 3, ...);
}
int function1(int arg1, int arg2, ...) {
// Define the function here
}
int function2(int arg2, int arg2, ...) {
//Define another function
}
The "walls" in matsp's analogy are these function declarations. You can in fact just declare them with some arguments and return some generic value (NULL works great for this) and then call them in your main, and the compiler will happily trundle along, like so:
Code:
int function1(int arg1, int arg2){
return NULL;
}
But this is beside the point of what you are doing. Look at the framework I gave, and look at your program. What would you do to fix it to make it structured like mine?