Main content: function without parameter details, function default return int type proof, return default return value, void pointer + + operation
First, the function without parameters when the details
The function should be void when there are no arguments
A function in the C language
void f ();
Pass parameter F (2) when used, no error, and error in C + +
It is best to add void to clarify that the function is parameterless
Second, the function default return type is int type
See procedure below
Return default returns 1
Detail: Return cannot return a pointer in the execution stack memory because the memory is automatically destroyed at the end of the function body
D. void pointer + + operation
void *p;
p++; Error in ANSI compilation, p++ and char* consistent in GNU compiler
#include <stdio.h> A () {return 3;//return;//directly written in this form the default is to return 1}b (int a, int b) {return a+b;} int main () {printf ("func A return =%d\n", A (2)); function no parameter should be declared void, in C does not declare the parameter is not error, in C + + will be error, so regardless of C + +, function without parameters declared void printf ("func b retunr =%d\n", b (300,5000)); This shows that the function has no return type and returns the int type printf ("-------------------------\ n") by default; void *p; p++;//uses the compiler GCC, mingw5 compilation pass (i.e. GNU), which they consider p++ as char* type, using VC6.0 compile error (i.e. ANSI) return 0;}
Output:
Program Ape's---C language details 27 (function without parameter details, function default return int type proof, return default return value, void pointer + + operation)