I need to add the numbers in the row array mentioned in the structure. for example I need the output of row=[ 4 5 6] and age= 25, how can i do with the above mentioned structure?? Please help !
基于此更新:
将要存储的元素数量放入数组定义中:
int row[1]; // This stores 1 element of type int
// you want to store 3 elements: 4, 5, 6, so...
int row[3]; // This is what you're looking for
记住一个数组:
int row[X];
从row[0]
到row[X-1]
。因此,在您的情况下X=3
,这意味着您的数组的最小/最大值是:
min = row[0]
max = row[3-1] = row[2]
这意味着您的代码应该执行以下操作:
pptr->row[0] = 4;
pptr->row[1] = 5;
pptr->row[2] = 6;
pptr->age = 25;
printf("%d\n",pptr->row[0]);
printf("%d\n",pptr->row[1]);
printf("%d\n",pptr->row[2]);
printf("%d\n",pptr->age);