syntax of a function 'return'

Is there somewhere a syntax tutorial for: return .

This function works well, but I can't find why the 'return' has 2 elements:
- (unsigned int) , and
- a calculation , as an ouput.

Can someone lead me to a reference document/tutorial, for detailled syntax of 'return'?

1
2
3
4
5
6
/* from K&R: returns random number 0 ... 32767.*/
int rand()
{
    rand_seed = rand_seed * 1103515245 +12345;
    return (unsigned int)(rand_seed / 65536) % 32768;
}
The syntax is (roughly)
return <expression>;.

In the above, (unsigned int) is a C-style type conversion, applied to the result of the division (rand_seed / 65536).

http://en.cppreference.com/w/cpp/language/explicit_cast
http://en.cppreference.com/w/cpp/language/return

Note: return is not a function.
Last edited on
Topic archived. No new replies allowed.