mikroC

making it simple...

mikroC - C Compiler for Microchip PIC microcontrollers

You can use goto to break out from any level of nested control structures. But, goto cannot be used to jump into block while skipping that block’s initializations

– for example, jumping into loop’s body, etc.

Use of goto statement is generally discouraged as practically every algorithm can be realized without it, resulting in legible structured programs. One possible application of goto statement is breaking out from deeply nested control structures:

for (...) { for (...) {

...

if (disaster) goto Error;

...

}

}

.

.

.

Error: /* error handling code */

Return Statement

Use the return statement to exit from the current function back to the calling routine, optionally returning a value. Syntax is:

return [expression];

This will evaluate the expression and return the result. Returned value will be automatically converted to the expected function type, if needed. The expression is optional; if omitted, function will return a random value from memory.

Note: Statement return in functions of void type cannot have an expression – in fact, you can omit the return statement altogether if it is the last statement in the function body.

 

 

page

 

MikroElektronika: Development tools - Books - Compilers

123