September 2001
Beginner
970 pages
23h 20m
English
Just what can you do with pointers? C offers six basic operations you can perform on pointers, and the next program demonstrates these possibilities. To show the results of each operation, the program prints the value of the pointer (which is the address to which it points), the value stored in the pointed-to address, and the address of the pointer itself. (If your compiler doesn't support the %p specifier, try %u or perhaps %lu for printing the addresses.)
Listing 10.13 shows the six basic operations that can be performed with pointer variables.
#include <stdio.h> int main(void) { int urn[3] = {100,200,300}; int * ptr1, * ptr2; ptr1 = urn; // assign an address to a pointer ptr2 = &urn[2]; ... |
Read now
Unlock full access