📘 Lesson · Lesson 54
Pointers in C
Pointers in C
What is a Pointer?
💡 Note
A pointer is a variable that stores the memory address of another variable.
Example
C
#include <stdio.h>
int main() {
int x = 10;
int *p = &x; // p stores address of x
printf("Value: %d\n", *p); // dereference: 10
printf("Address: %p\n", p);
return 0;
}Output:
Value: 10 Address: 0x7ffe...
Value: 10 Address: 0x7ffe...
Key Operators
&xgives the address of x.*pgives the value stored at that address (dereference).
Summary
- A pointer holds an address;
&gets an address,*reads the value there.
Pointer क्या है?
💡 Note
Pointer एक variable है जो दूसरे variable का memory address रखता है।
Example
C
#include <stdio.h>
int main() {
int x = 10;
int *p = &x; // p, x का address रखता है
printf("Value: %d\n", *p); // dereference: 10
printf("Address: %p\n", p);
return 0;
}Output:
Value: 10 Address: 0x7ffe...
Value: 10 Address: 0x7ffe...
मुख्य Operators
&xx का address देता है।*pउस address पर रखी value देता है (dereference)।
सारांश
- Pointer address रखता है;
&address देता,*वहाँ की value पढ़ता है।