Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Understanding pointers and memory addresses in C
#1
Pointers are variables that store memory addresses.

int num = 10;
int *ptr; // Declare a pointer
ptr = # // Assign the address of num to the pointer

printf("Value of num: %d\n", num); // Output: 10
printf("Address of num: %p\n", &num); // Output: Address in hexadecimal format
printf("Value of ptr: %p\n", ptr); // Output: Address of num
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Uninitialized pointers in C Qomplainerz 0 221 07-26-2023, 07:10 AM
Last Post: Qomplainerz
  File pointers and streams in C Qomplainerz 0 227 07-25-2023, 01:24 PM
Last Post: Qomplainerz
  Dynamic memory allocation in C (malloc, free) Qomplainerz 0 234 07-25-2023, 11:42 AM
Last Post: Qomplainerz
  Passing pointers to functions in C Qomplainerz 0 277 07-25-2023, 11:42 AM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 9 Guest(s)