Scientific Programming and Computer Architecture 20
Scientific Programming and Computer Architecture 20
0x7fff3cb8e414 0x7fff3cb8e400 37
The value of x is printed as 37, as we may have expected. The address of x and the value of list are
printed in hexadecimal as indicated by the 0x at front. Thus, each address is 48 bits long. Figure 1.3↑ may give the
impression that each address is the address of a location in physical memory. In fact, the addresses that are printed
out are virtual addresses, a concept we will discuss in later chapters.
The printf() function used on line 10 is part of the standard C library. Its declaration will be in the
standard header file stdio.h, which is included on line 1. The C compiler knows where to look for this header file.
As already noted, arrays and pointers are almost equivalent in C. The principal advantage of thinking of arrays in
this way arises in passing arrays as arguments to functions. Here we use the Aitken example to illustrate how arrays
may be passed as pointers.
The file aitken.c begins with two directives :
#include <assert.h>
#include "aitken.h"
https://divakarvi.github.io/bk-spca/spca.html[20-1-2019 23:44:49]