如何将struct
的数组分配给typedef struct
,结构类似。将结构数组赋值给一个typedef结构
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int age;
int height;
} Person[3];
struct internalStruct {
int age;
int height;
};
int main(void) {
//Possible
Person bob = {{7,5},{4,2},{4,3}};
//Is it possible to assign array to struct?
struct internalStruct intr[3] = {{4,32},{2,4},{2,4}};
Person job = intr; // Does not work :(.
printf("%d", jon[0].height);
return 0;
}
是否有任何理由不执行'struct internalStruct {int age; int height; }; typedef struct internalStruct Person [3];'? –
我只是想了解内存结构是否相同(3的数组的typedef是相同的内存结构,以及只是一个普通的3结构数组,我实际上不是在C编码。 – Anonymous