1 / 6

Understanding Pointers and Arrays in C Programming: A Comprehensive Guide

This guide delves into the intricate relationship between pointers and arrays in C programming. It covers how arrays can be accessed using both array subscript notation and pointer/offset notation, illustrated with examples. For instance, the array 'b' can be referenced as 'b[0] = 10' or through pointer notation as '*(b + 0) = 10'. It also examines pointer subscript notation, such as 'bPtr[0] = 10', and demonstrates how pointers can facilitate array manipulation. Additionally, sample program outputs are included to enhance understanding.

donnel
Télécharger la présentation

Understanding Pointers and Arrays in C Programming: A Comprehensive Guide

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pointers in C The relationship between pointers and arrays

  2. fig07_20.c (Part 1 of 2)

  3. fig07_20.c (Part 2 of 2)

  4. Array b printed with: Array subscript notation b[ 0 ] = 10 b[ 1 ] = 20 b[ 2 ] = 30 b[ 3 ] = 40 Pointer/offset notation where the pointer is the array name *( b + 0 ) = 10 *( b + 1 ) = 20 *( b + 2 ) = 30 *( b + 3 ) = 40 Pointer subscript notation bPtr[ 0 ] = 10 bPtr[ 1 ] = 20 bPtr[ 2 ] = 30 bPtr[ 3 ] = 40 Pointer/offset notation *( bPtr + 0 ) = 10 *( bPtr + 1 ) = 20 *( bPtr + 2 ) = 30 *( bPtr + 3 ) = 40 Program Output

  5. fig07_21.c (Part 1 of 2)

  6. fig07_21.c (Part 2 of 2) Program Output string1 = Hello string3 = Good Bye

More Related