Skip to content

Commit f3cf008

Browse files
committed
add decrement of pointer in C
1 parent 50fbfd2 commit f3cf008

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

a.out

0 Bytes
Binary file not shown.

pointer-Arithmetic.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
// increment
2+
// #include <stdio.h>
3+
// int main(){
4+
// int age = 10;
5+
// int *ptr = &age;
6+
// printf("%u\n" ,ptr);
7+
// *ptr++ ;
8+
// printf("%u\n" ,ptr);
9+
10+
// return 0;
11+
// }
12+
13+
// ============= . decrement
14+
215
#include <stdio.h>
316
int main(){
4-
int age = 10;
5-
int *ptr = &age;
6-
printf("%u\n" ,ptr);
7-
*ptr++ ;
8-
printf("%u\n" ,*ptr);
17+
int age = 12;
18+
int *ptr = &age;
19+
printf("%u\n", ptr);
20+
*ptr--;
21+
printf("%u\n", ptr);
922

1023
return 0;
1124
}

0 commit comments

Comments
 (0)