我正被迫用C语言开发一个项目。我没有太多的C语言知识,但我假设答案很简单。
struct s1 {
char *text;
int num;
};
struct s2 {
struct s1 vals[5];
int numbers;
};
假设s2已被填充。如何从s1访问num?我以为我会做类似的事情
struct s2 temp;
//temp is populated somehow, doesn't matter in the case
printf("%d\n", temp.vals[0]->num);
但这不起作用。有什么建议?
使用temp.vals[0].num
。该->
如果您使用的是指向一个struct运营商只能用。您正在直接使用结构。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句