Standard C++ Library Reference ISO/IEC (VERSION3)
Next
Functions
You write functions to specify all the actions that a program performs when it executes. The
type of a function tells you the type of result it returns (if any). It can also tell you the types of
any arguments that the function expects when you call it from within an expression.
This document describes briefly just those aspect of functions most relevant to the use of the
Standard C library:
Argument promotion occurs when the type of the function fails to provide any information
about an argument. Promotion occurs if the function declaration is not a function prototype or if
the argument is one of the unnamed arguments in a varying number of arguments. In this
instance, the argument must be an rvalue expression. Hence:
An integer argument type is promoted.●
An lvalue of type array of Ty becomes an rvalue of type pointer to Ty.●
A function designator of type function returning Ty becomes an rvalue of type pointer to
function returning Ty.
●
An argument of type float is converted to double.●
A do statement executes a statement one or more times, while its test-context expression has a
nonzero value:
do
statement
while (test);
An expression statement evaluates an expression in a side-effects context:
printf("hello\n"); call a function
y = m * x + b; store a value
++count; alter a stored value
A for statement executes a statement zero or more times, while the optional test-context
expression test has a nonzero value. You can also write two expressions, se-1 and se-2, in
a for statement that are each in a side-effects context:
for (se-1; test; se-2)
statement
An if statement executes a statement only if the test-context expression has a nonzero value:
if (test)
statement