C - Language Theory
Pointers
- Pointer is a variable that stores the address of the another variable. This variable can be int, float, char...etc.
Syntax:
Data Type variable_name:int *p; (Pointer to an integer variable)
float *p; (Pointer to a float variable)
char *p; (Pointer to a character variable)
Pointers in C:
Pointer is a variable that stores the address of the another variable. This variable can be int, float, char...etc.
Syntax: |
---|
data type *variable_name; int *p; (Pointer to an integer variable) float *p; (Pointer to a float variable) char *p; (Pointer to a character variable) Example:#include <studio.h> int main (void) { int var = 20; int *ip; ip = &var; printf("Address of var variable:%x", &var); printf("value of var variable:%d", var); /* address stored in pointer variable*/ printf("Address stored in ip variable:%x", ip); /* access the value using the pointer*/ printf("Value of *ip variable:%d", *ip); return 0; } Output:Address of var variable: bffd8b3c value of var variable: 20 Address stored in ip variable: bffd8b3c Value of *ip variable: 20 |