Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 3. Handling Data > Using Pointer Math

Using Pointer Math

If you point to items arranged one after another in memory, such as in an array, you can increment or decrement pointers to point to the next or previous item. For instance, the following example prints the first number in an array and then the second number by incrementing a pointer:

float values[4] = {0.0, 1.0, 2.0,
  3.0};

float *pointer = &values[0];

printf("*pointer = %2.1f\n", *pointer);

printf("*(++pointer) = %2.1f",
  *(++pointer));


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial