如何使用指针运算来打印结构的特定成员?我有一个2个成员的结构。我想通过操作指向该结构的指针的内存来打印出成员j
。带结构的指针运算
#include <stdio.h>
#include <conio.h>
typedef struct ASD
{
int i;
int j;
}asd;
void main (void)
{
asd test;
asd * ptr;
test.i = 100;
test.j = 200;
ptr = &test;
printf("%d",*(ptr +1));
_getch();
}
没有“指针的记忆”之类的东西。也许你的意思是“操纵指针”? – 2011-12-28 15:32:39
你为什么要这样做,而不是使用' - >'运算符? – 2011-12-28 15:33:00
@ mr.anubis当然是。 – 2011-12-28 15:43:01