Today,when I was reading the MSDN,I encountered the following codes:
void draw( int I, long L );
long sq( int s );
int main()
{
long y;
int x;
y = sq( x );
draw( x, y );
return();
}
long sq( int s )
{
return( s * s );
}
void draw( int I, long L )
{
/* Statements defining the draw function here */
return;
}
Of course,it didn’t work,so I change the
return();
in main function to
return 0;
It works with a caution .
I have two problems about this code:
1.Why does Microsoft use return ();Is this just a mistake?Or other reasons?
2.what does return; in the draw function mean?I think it is not necessary,why does it exsit in the function?
I agree with the other posters, also even though the return in the draw function isn’t necessary in this case, as there’s an implicit return statement at the end of the function, it is allowable and indeed may be used to exit a function early so that further code in a function is avoided e.g.