Add some more pointers experiments
This commit is contained in:
parent
0dd9280818
commit
c564389e8b
1 changed files with 23 additions and 0 deletions
23
c_modern_approach/Pointers/more.c
Normal file
23
c_modern_approach/Pointers/more.c
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int x = 10;
|
||||||
|
int * pX = &x;
|
||||||
|
printf("int value: %d\n", x);
|
||||||
|
printf("int address: %p\n", pX);
|
||||||
|
*pX = 15;
|
||||||
|
printf("int value after modifing pointer: %d\n", x);
|
||||||
|
printf("int address: %p\n", pX);
|
||||||
|
x = 20;
|
||||||
|
printf("int value: %d\n", x);
|
||||||
|
printf("int value from pointer: %d\n", *pX);
|
||||||
|
printf("int address: %p\n", pX);
|
||||||
|
|
||||||
|
char *p = "Hello";
|
||||||
|
printf("Char value: %s\n", p);
|
||||||
|
printf("Char address: %p", &p);
|
||||||
|
char p_value = *p;
|
||||||
|
printf("Char p_value: %c\n", p_value);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue