c - 在 C 中使用数组结构函数

标签 c arrays function struct

我要考试了。我有联赛表。有团队名称、简称、积分等,如您在结构中看到的那样。我必须使用函数来编写 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/

相关文章:

c - 使用直方图查找数组中最常见的字母

c - 从键盘上介绍一些学生和他们的分数

php - 如何在没有循环的情况下将mysql数组加载到数组中?

c - C 函数调用的返回值?

创建线程循环

javascript - 将数组转换为 JSON

arrays - 数组 "view"可能在不同类型的数组上吗?

php - 将带有媒体查询和其他最终情况的 css 解析为 php 数组

c - 数列中的第 n 个元素,其中数字可被其数字之和整除

c指针引用和取消引用