巴罢2 2022-04-06 23:29 采纳率: 50%
浏览 14
已结题

自定义数据结构名称后函数无法识别,编译结果为declare(未声明)?

问题遇到的现象和发生背景

使用typedef 重命名了一个数据结构,在使用自定义void函数的时候,传入该类型参数;结果显示编译认不出 这个重命名 的东西。

问题相关代码,请勿粘贴截图

问题就在_void finpu(STU student[]) { //输入模块,将三个数据结构填入相应的数值_这里

//信息管理系统,增删改查;包含学生的学号,姓名,性别,C语言,数学以及英语成绩

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define num 3


void finpu(STU student[]) { //输入模块,将三个数据结构填入相应的数值
    for(int i=0; i<num; i++) {
        printf("please input the basenum of the student%d:\n",i+1);
        gets(basenum);
        getchar();
        printf("input the name of the student%d",i+1);
        gets(name);
        printf("please input the gender of the student!attetion:male for M,female for F!\n") ;
        getchar(student[i])
        getchar();
        printf("input the score of the student%d,including clanguage,math,english!\n(deparate those scores by '')",i+i);
        scanf("%d %d %d",&student[i].clanguage,&student[i].math,&student[i].english);
    }
}
void search(STU student[]) {//搜索模块,将数据搜索并且输入
    char *ser;
    printf("please input the basic number of the student:\n");
    gets(ser);
    for(int i=0; i<num; i++) {
        if(!strcmp(ser,student[i].basenum) {
        printf("base information of this student show as below:\n");
            printf("name-->%s\n",student[i].name);
            printf("gender-->%c\n",student[i]->gender);
            printf("%c \t%c \t%c \t",student[i].clanguage,student[i].math,student[i].english);
            break;
        } else {
            printf("查无此人,请输入正确的学号!\n");
        }
    }


}

int main(void) {
    typedef struct stu {
        char basenum[10];
        char name[10];
        char gender;
        char clanguage,math,english;
    } STU;
    STU student[num];
    finpu(STU student);

}

运行结果及报错内容
         error:   variable of field 'finpu' declared void
         error:  'STU' was not declared in this scope 
我的解答思路和尝试过的方法
             改“STU”这个名称,结果没卵用
我想要达到的结果


  • 写回答

1条回答 默认 最新

  • IT_阿水 2022-04-07 11:31
    关注

    你要把结构体的定义改成全局的,放到你要使用的函数最前面。而且你这代码还有好多其它的错误

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 4月15日
  • 已采纳回答 4月7日
  • 创建了问题 4月6日

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装