Pointer एक ऐसा variable होता है जो किसी दूसरे variable का memory address store करता है। यह C प्रोग्रामिंग की सबसे powerful features में से एक है।
datatype *pointer_name;
उदाहरण:
int *ptr;
#include <stdio.h>
int main() {
int num = 10;
int *ptr;
ptr = #
printf("Value of num: %d\n", num);
printf("Address of num: %p\n", &num);
printf("Value stored in ptr: %p\n", ptr);
printf("Value pointed by ptr: %d\n", *ptr);
return 0;
}
Value of num: 10
Address of num: 0x7ffee602b9c4
Value stored in ptr: 0x7ffee602b9c4
Value pointed by ptr: 10
Operator | Description |
---|---|
& | Address of operator |
* | Dereference operator (value at address) |
int *p = NULL;
if (p != NULL) {
// safe to use
}
C Language में Pointers एक core concept है। यह beginners के लिए थोड़ा technical हो सकता है, लेकिन एक बार समझ में आने पर आप memory management और efficient coding में expert बन सकते हैं।