如何將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