UMBC CMSC 201 Spring '02 | CSEE | 201 | 201 S'02 | lectures | news | help |
Recall that C uses call by value for scalars, which means that (a copy of) the address of i is passed to scanf. The scanf routine reads in the data, and places it in the indicated address.
In general, if a subroutine needs to modify a scalar variable, it needs to receive the address of that variable as a parameter. For example,