0
#include<stdio.h>
#include<stdlib.h>
struct test
{
int x;
int *y;
};
main()
{
struct test *a;
a = malloc(sizeof(struct test));
a->x =10;
a->y = 12;
printf("%d %d", a->x,a->y);
}
我得到的O/P,但有一个警告输入数据以构造部件是指针
warning: assignment makes pointer from integer without a cast
和
warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘int *’
如何输入一个值到* Y结构测试
道格的答案是100%正确的。不过,我认为你真正需要的是阅读指针,我不认为特别解决这个情况会对你有所帮助。有很好的教程,你可以谷歌。 – slezica