< Back
Page 13 of 13
This chapter is from the book
Exercises
-
Rewrite this function as a block:
int k(void) { return 1; }
-
Write a function create_k that accepts a single integer argument i and returns a block. The returned block accepts no arguments and always returns the value of i passed to create_k(). Use this function in a test program. (Be careful with the block memory management!)
-
Define two blocks called add_one and add_two that accept no arguments and return nothing. These should both increment the same integer by one or two. (You will need the __block storage specifier.)
-
Use typedefs to simplify the following block reference declaration:
int (^(*(^get_block_factory_funcptr)(void))(int))(void);
< Back
Page 13 of 13