pointer add/sub/comp
#include <stdio.h>
int main() {
// Write C code here
int i = 34 , a ,b ;
int *ptr = &i;
printf("address of i is : %u\n " , ptr);
a=ptr++; // 4 bits for 1 integer ... therefore ptr + 4
ptr= ptr+1;
b=ptr--;
printf("next address of i is : %u\n " , ptr);
printf("%d\n", (b-a));
printf("%d\n", b);
printf("%d\n", a);
if (a==b){
printf("eq_true");
}
else if (a<=b){
printf("less_true");
}
else if (a>=b){
printf("grt_true");
}
return 0;
}
Comments
Post a Comment