Skip to content

Instantly share code, notes, and snippets.

@joegasewicz
Last active November 25, 2022 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joegasewicz/3e73778228d2d296e720a9d7a0f14da0 to your computer and use it in GitHub Desktop.
Save joegasewicz/3e73778228d2d296e720a9d7a0f14da0 to your computer and use it in GitHub Desktop.
C Pointers to Arrays
/* ====================================================================== */
/* 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