c-programming:pointers:intro
Introduction
/* Reference */ #include <stdio.h> int main() { int a = 5; printf("The value of a is: %d\n", a); printf("The address of a is: %p\n", &a); return 0; }
/* Pointer */ #include <stdio.h> int main() { int a; int *p; a = 5; p = &a; printf("The value of a is: %d\n", a); printf("The address of a is: %p\n", &a); printf("The address of a is: %p\n", p); return 0; }
/* Dereference */ #include <stdio.h> int main() { int a; int *p; a = 5; p = &a; printf("The value of a is: %d\n", a); printf("The value of a is: %d\n", *p); printf("The address of a is: %p\n", &a); printf("The address of a is: %p\n", p); *p = 10; printf("New value of a is: %d\n", a); printf("New value of a is: %d\n", *p); printf("The address of a is: %p\n", &a); printf("The address of a is: %p\n", p); return 0; }
/* Uninitialize */ #include <stdio.h> int main() { int *p; int n = *p; printf("Uninitialized value of n is: %d\n", n); printf("Uninitialized value of p is: %p\n", p); return 0; }
c-programming/pointers/intro.txt · آخرین ویرایش: 2024/04/19 17:54 توسط pejman
