I've noticed alot of the more experienced coders when they post code with functions it looks like.
Code:
#include <iostream.h>
using namespace std;
int getint();
int main (int argc, char *argv[])
{
int c;
c = getint();
cout <<c<<"\n";
system("PAUSE");
return EXIT_SUCCESS;
}
int getint()
{
int c;
cin>> c;
return c;
}
I usually write my programs like this
Code:
#include <iostream.h>
using namespace std;
int getint()
{
int c;
cin>> c;
return c;
}
int main (int argc, char *argv[])
{
int c;
c = getint();
cout <<c<<"\n";
system("PAUSE");
return EXIT_SUCCESS;
}
I know it is a small difference, but I find small differences usually turn to big differences later. Can anyone explain why they declare their functions on top of main and then define them underneath? In my high school computer programming class (7 yrs ago) my teacher had us declare and define above the statement of int main. Does this maybe keep functions from needing to be defined in a certain order? I'm sure this is a beginner question, but thanks for your time.
Ohh and why:
int main (int argc, char *argv[])
7 yrs ago I was taught
int main()