为了获得我做过的结构数组:
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};
}
答案 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}};
}