为了获得结构数组我做了:
int main() {
typedef struct {
int size;
double time;
} timming_s;
timming_s timming[5];
timming[0] = (timming_s){(int)1e5, 0.0};
timming[1] = (timming_s){(int)2e5, 0.0};
}
是否有更紧凑的形式来获得它?我试图写:
int main() {
struct timming_s {
int size;
double time;
} timming[5];
timming[0] = {(int)1e5, 0.0};
timming[1] = {(int)2e5, 0.0};
}
最佳答案
int main(void) {
struct {
int size;
double time;
} timming[5] = {{1e5, 0}, {2e5, 0}};
// } timming[5] = {{.size = 1e5, .time = 0}, {.size = 2e5, .time = 0}};
}