标签:cores turn ++ pthread info sizeof 数组 变长数组 scores
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <time.h> #include <unistd.h> typedef struct score_s{ char name[20]; int scores[0]; }score; int main() { score *scoreInfo = malloc(sizeof(score) + sizeof(int) * 3); strcpy(scoreInfo->name, "guanxianseng"); scoreInfo->scores[0] = 100; scoreInfo->scores[1] = 110; scoreInfo->scores[2] = 120; printf("name:%s\n", scoreInfo->name); for (int i = 0; i < 3; i++) { printf("score:%d\t", scoreInfo->scores[i]); } printf("\n"); return 0; }
标签:cores turn ++ pthread info sizeof 数组 变长数组 scores
原文地址:https://www.cnblogs.com/luckygxf/p/12508226.html