我要考试了。我有联赛表。有团队名称、简称、积分等,如您在结构中看到的那样。我必须使用函数来编写 txt 文件,但我不能将函数与数组结构一起使用。我的代码如下。当我使用这样的函数时,codeblocks 给我错误。我该如何使用?
(我找到了答案。如果您也需要,下面有一个链接。 http://kursattopcuoglu.blogspot.com/2010/06/ilk-donem-final-sorusuna-benzer-bir.html )
struct teams{
char shortname;
char teamname;
int points;
};
void table(struct teams);
int main{
team[2]={'A',"Fenerbahce",0},{'B',"Galatasaray",0};
....
}
void(struct teams team[2]{
printf("%d",team[0].points);
最佳答案
有很多答案,但没有一个完整。以下为:
struct teams{
char shortname;
char *teamname;
int points;
};
void table(struct teams *team);
int main(void){
struct teams team[2]={{'A',"Fenerbahce",0},{'B',"Galatasaray",0}};
table(team);
// ....
}
void table(struct teams *team){
printf("%d",team[0].points);
}
关于c - 在 C 中使用数组结构函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55164090/