对于基本数据类型,指针如何在 C 中递增?我无法理解为什么下面代码中的差异没有给我内存位置的字节差异,它给了我 1..
Here is my code::
char c1='c';
char *c=&c1;
int i1=1;
int *i=&i1;
long l1=1;
long *l=&l1;
float f1=1.1;
float *f=&f1;
double d1=1.3;
double *d=&d1;
printf("c =%u ,c +1=%u\n",c,c+1);
printf("i =%u ,i +1=%u\n",i,i+1);
printf("l =%u ,l +1=%u\n",l,l+1);
printf("f =%u ,f +1=%u\n",f,f+1);
printf("d =%u ,d +1=%u\n",d,d+1);
printf("c diff =%u\n",(c+1)-(c));
printf("i diff =%d\n",(i+1)-(i));
printf("l diff =%u\n",(l+1)-(l));
printf("f diff =%u\n",(f+1)-(f));
printf("d diff =%u\n",(d+1)-(d));
printf("c diff =%u\n",(c)-(c+1));
printf("i diff =%u\n",(i)-(i+1));
printf("l diff =%u\n",(l)-(l+1));
printf("f diff =%u\n",(f)-(f+1));
printf("d diff =%u\n",(d)-(d+1));
Output::c =1636923 ,c +1=1636924
i =1636896 ,i +1=1636900
l =1636872 ,l +1=1636876
f =1636848 ,f +1=1636852
d =1636820 ,d +1=1636828
c diff =1
i diff =1
l diff =1
f diff =1
d diff =1
c diff =4294967295
i diff =4294967295
l diff =4294967295
f diff =4294967295
d diff =4294967295
Why I am not getting "i diff =%d\n",(i+1)-(i) ==>> 4