Last active
November 25, 2022 18:40
-
-
Save joegasewicz/3e73778228d2d296e720a9d7a0f14da0 to your computer and use it in GitHub Desktop.
C Pointers to Arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ====================================================================== */ | |
/* Pointers to Arrays */ | |
/* ====================================================================== */ | |
// point to first item in an array | |
char arr[] = {'a', 'b', 'c'}; | |
// apply the address operator to the first element in the array | |
char *arrPtr = &arr[0]; // without address operator you would get a value | |
// C compiler treats the array name (arr) without subscript ([]) | |
// as a pointer to the array. | |
// assignment without subscript has the effect of producing a pointer | |
// to the first element. | |
char *arrPtr2 = arr; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment