Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这两个结构:
typedef struct { char name[20]; int num; int score; } player; typedef struct { char name[20]; player *players; } team;
*players我需要知道我的team结构中每个存储的元素数量。谢谢!
*players
team
你不能。 players是指向 N 个player实例的指针。它只携带一个地址的信息。它不是一个数组;它是一个指针。
players
player
您必须单独存储结构中的元素数量。
typedef struct { char name[20]; player *players; size_t num_players; } team;
顺便说一句,你最好希望 Jarrod Saltalamacchia 永远不会加入这个团队。