What is pointer?
What is pointer?
Best answer
Answer: a pointer is a variable that stores the memory address of another variable.
It is declared with an asterisk: data_type *pointer_name;
int x = 10;
int *p; /* p can hold the address of an int */
p = &x; /* & gives the address of x */
printf("%d", *p); /* * gives the value at that address: 10 */
*p = 25; /* changes x to 25 */
& (address-of operator) gives the address of a variable.* (indirection / dereference operator) gives the value stored at the address held in the pointer.Pointers are used for call by reference (letting a function change the caller's variables), working efficiently with arrays and strings, dynamic memory allocation (malloc), and building data structures like linked lists.
Log in or create a free account to answer this question.