Instructions

188Compiler
© 2013 Conrad Electronic
}
When calling up a function all parameters must always be stated. The following call up is inad-
missible:
func1(); // func1 gets 2 parameters!
func1(128); // func1 gets 2 parameters!
Return Parameters
It is not only possible to pass parameters. A function can also offer a return value. The data type of
this value is during function definition entered ahead of the function name. If no value needs to be re-
turned the data type used will be void.
int func1(int a)
{
return a-10;
}
The return value is within the function stated as instruction "return Expression". If there is a function
of the void type then the return instruction can be used without parameters in order to leave the
function.
References
Since it is not possible to pass on arrays as parameters the access to parameters is possible
through references. For this a pair of brackets is written after the parameter names in the parameter
declaration of a function.
int StringLength(char str[])
{
int i;
i=0;
while(str[i]) i++; // repeat character as long as unequal zero
return(i);
}
void main(void)
{
int len;
char text[15];
text="hello world";
len=StringLength(text);
}
In main the reference of text is presented as parameters to the function StringLength. If in a function
a normal parameter is changed then the change is not visible outside this function. With references
this is different. Through parameter str in StringLength the contents of text can be changed since str