Function definition

Top 

Functions are defined by description of the type of result, formal parameters and composite operator (block) that describe the actions carried out by the function.

Example:

int                          the type of result

  func(                      function name

       long a, char str[]    list of parameters, which describes the names and types

      )

{                            composite operator

  // ...

  return 0;                  returned value

}

The return operator can not return any value or return the value of the expression included in this operator.

The function, which does not return a value, shall be described as having type void.

One or several last parameters on the list can assume the default values. Examples:

int func(int x, int y = 0);

int f1(char s[], char s1[] = "null", int x = func(0));

void errmesg(char s[])

{

  printf{"***Error: %s", s);

  // the Return operator (explicit) is not required

}