指標 指標

 #include<stdio.h>

#include<stdlib.h>
 
int main()
{
int a=20,b=40,*d,*e;
d=&a;
e=&b;
printf("%d\n",(*d+*e));
system("pause");
return 0;
}
指標與陣列 指標與陣列

 #include<stdio.h>

#include<stdlib.h>
 
int main()
{
int a[10]={10,20,30,30,40,50,60,60,70,80};
int *d,t;
d=&a[0];
for(t=0;t<10;t++)
printf("-- %d \n",a[t]);
for(t=0;t<10;t++)
printf("++ %x\n",(d+t));
for(t=0;t<10;t++)
*(d+t)=t;
for(t=0;t<10;t++)
printf("-- %d \n",a[t]);
system("pause");
return 0;
}
 
test1 test1

 #include<stdio.h>

#include<stdlib.h>
 
int main()
{
int a[10]={10,20,30,30,40,50,60,60,70,80};
int *d,t,sum=0;
d=&a[0];
for(t=0;t<10;t++)
sum+=*(d+t);
printf("%d\n",sum);
system("pause");
return 0;
}