Pointer

<aside> ๐Ÿ’ก

C Pointer is..

The derived data type that is used to store the address of another variable and can also used to access and mainpulate the variableโ€™s data stored at that location.

*From. https://www.tutorialspoint.com/cprogramming/c_pointers.htm*

</aside>

Pointer Declaration & Initialization

Example of Using Pointer

#include <stdio.h>

int main() {
  int x = 10;

  // Pointer declaration and initialization
  int * ptr = & x;

  // Printing the current value
  printf("Value of x = %d\\n", * ptr);

  // Changing the value
  * ptr = 20;

  // Printing the updated value
  printf("Value of x = %d\\n", * ptr);

  return 0;
}

// Output
// Value of x = 10
// Value of x = 20

Size of a Pointer Variable

// ์˜ˆ: 8 (64๋น„ํŠธ ์‹œ์Šคํ…œ)
printf("%lu\\n", sizeof(int*));
// ์˜ˆ: 8 (64๋น„ํŠธ ์‹œ์Šคํ…œ)
printf("%lu\\n", sizeof(char*));

Pointer Arithmetics in C