Programmer --- C language details 27 (when the function has no parameters, the function returns the int type proof by default, the return value by default, and the void pointer ++ Operation)
Main Content: details when the function has no parameters, proof of int type returned by the function by default, return value by default, void pointer ++ operation
I. Details of functions without Parameters
Void should be added when the function has no Parameter
A function in C Language
Void f ();
Pass the parameter f (2) in use; no error is reported, but an error is reported in c ++.
It is best to add void to specify that the function has no parameters.
2. The default return type of the function is int.
See the following program
3. return returns 1 by default.
Details: return cannot return the pointer in the execution stack memory because the function body is automatically destroyed when it ends.
Iv. void pointer ++ operation
Void * p;
P ++; // errors in ANSI compilation. In the GNU Compiler, p ++ is consistent with char *.
# Include
A () {return 3; // return; // write this form directly. By default, return 1} B (int a, int B) {return a + B ;} int main () {printf ("func a return = % d \ n", a (2); // if the function has no parameters, it should be declared as void, if the parameter is not declared in c and no error is reported, an error is reported in C ++, if the function has no parameter, it is declared as void printf ("func B retunr = % d \ n", B (,); // The function has no return type, the int-type printf ("------------------------- \ n"); void * p; p ++; // compiled by using the gcc and mingw5 compilers (GNU ), they think that p ++ is of the char * type and use VC6.0 to compile the error (that is, ANSI) return 0 ;}
Output: