Arrays of Pointers

So far you have used only single pointer variables, but you can also use arrays of pointer variables if you need to store a series of addresses. One such need for an array of pointers is when dealing with a series of text strings (character arrays). This will be demonstrated using the command-line arguments that a C program can receive when it is started.

When you run a compiled C program, you can optionally add a number of arguments that are passed to that program. From a command-line interface, arguments are separated by one or more blank spaces, and come after the application name (Figure 9.15). In this figure, pointer9 is the program name and aaa and bbb are two separate arguments.

Figure 9.15. C programs can receive a ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.