UbiQ Scenario Manager User Manual
54
* Return type
* Arguments
Overview of functions
Functions must have a definition and should have a declaration, although a definition
can serve as a declaration if the declaration appears before the function is called.
The function definition includes the function body °™ the code that executes when
the function is called.
A function call passes execution control from the calling function to the called func-
tion. The arguments, if any, are passed by value to the called function. Execution of a
return statement in the called function returns control and possibly a value to the call-
ing function.
Return type
The return type of a function establishes the size and type of the value returned by
the function and corresponds to the type-specifier. The type-specifier can specify any
fundamental type. If you do not include type-specifier, the return type int is assumed.
The return type given in the function definition must match the return type in declara-
tions of the function elsewhere in the program. A function returns a value when a
return statement containing an expression is executed. The expression is evaluated,
converted to the return value type if necessary, and returned to the point at which the
function was called. If a function is declared with return type void, a return statement
containing an expression generates a warning and the expression is not evaluated.
The following examples illustrate function return values.
/* Sum the values between 0 and num. */
sum(int num)
{
int running_sum;
running_sum = 0;
while(num>0) {
running_sum = runni num;
num = num - 1;
}
return(running_sum);
}
You need not declare functions with int return type before you call them, although
prototypes are recommended so that correct type checking for arguments and return
values is enabled.
Arguments
The arguments in a function call have this form:
expression ( expression-list ) /* Function call */
Summary of Contents for UbiQ
Page 1: ...User Manual UbiQ Scenario Manager User Manual V1 03...
Page 4: ...UbiQ Scenario Manager User Manual iv...
Page 7: ...Chapter 1 1 Introduction...
Page 13: ...Chapter 2 2 Getting Started...
Page 37: ...Chapter 3 3 Tutorials...
Page 47: ...Chapter 4 4 Basic of Smart C Script Language...
Page 62: ...UbiQ Scenario Manager User Manual 56...