简单理解下指针
因为要做一个比较完善的管道通信,传递一些较为复杂的数据,用指针转来转去。
在这里简单写点代码,理解下指针,代码copy下运行下,看看temp++之前和之后的输出,做下简单的比较就好了,
时间有点紧,所以代码不是特别特别的规范……只做个简单的测试
#include <string>
int main()
{
int *a;
int *temp;
int b[10];
memset(b, 0, 10);
b[0] = 1;
b[1] = 2;
temp = b;
a = temp;
printf("b=%ld\n", b);
printf("temp=%ld\n", temp);
printf("a=%ld\n", a);
printf("*temp=%d\n", *temp);
printf("*a=%d\n", *a);
printf("\nNow temp++ ------------------------\n");
temp++;
printf("b=%ld\n", b);
printf("temp=%ld\n", temp);
printf("a=%ld\n", a);
printf("*temp=%d\n", *temp);
printf("*a=%d\n", *a);
getchar();
return 0;
}