Every variable in C is stored at a memory address. You can find that address using the & operator.
A pointer is a variable that holds the memory address of another variable. A pointer is declared with *
To declare a pointer: int *ptr;
To assign it the address of a variable: ptr = &x;
Dereferencing a pointer means accessing the value at the memory location it points to. Use *ptr to do this.
Pointers can be reassigned to point to different variables, as long as types match.
Use %p with printf() to print pointer addresses.
You can use pointers to modify a variable's value by referencing its memory address. This is useful for updating values inside functions or performing direct memory manipulation.
*ptr is used to dereference the pointer and access/change the value.&var is used to get the address of a variable.What will this print?
A. Address of xB. 10C. Errorint x = 10;
int *ptr = &x;
printf("%d", *ptr);Ask the AI if you need help understanding or want to dive deeper in any topic