Together these cleared up a lot of my confusion with this chapter:
(1) A function can return more than one variable. It can return any number of variables you like, in fact: so long as they are wrapped in a struct. This was raised in an earlier topic.
(2) I asked myself: Why does modf() require memory addresses and not just variable names? Why can’t it be modf(float, intVariable, fractVariable)? So I went into XCode to see if I could make such a function.
I couldn’t. Reason being: When you pass a variable into a function it can operate on the value passed but not the actual container that information is stored in. To do that the function would need to know the name of your variable in advance. This is possible if you are writing a small programme but it’s not very helpful for general application or portability. By passing in the memory address, you are giving it something it can use to actually change the variable you just created.
Well, that took me a while to figure out so hope it saves you some time!