Pointer in C
C provides full support for pointers, including pointer arithmetic, double pointers and function pointers. Below is the implementation of pointers in C:
#include <stdio.h>
void geeks()
{
int var = 10;
// declare pointer variable
int* ptr;
// note that data type of ptr and var must be same
ptr = &var;
// assign the address of a variable to a pointer
printf("Value at ptr = %p \n", ptr);
printf("Value at var = %d \n", var);
printf("Value at *ptr = %d \n", *ptr);
}
// Driver program
int main()
{
geeks();
return 0;
}
Output
Value at ptr = 0x7ffe4ac7635c Value at var = 10 Value at *ptr = 10
Pointer in programming
Pointer is a variable that stores the memory address of another variable. Pointers are a powerful feature of many programming languages, including C, C++, and others. They provide a way to simulate call-by-reference, create complex data structures, and interact with the operating system.