鱼C论坛

 找回密码
 立即注册
查看: 2076|回复: 4

求助一个学生系统的问题

[复制链接]
发表于 2021-3-11 21:31:25 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>

  4. typedef struct
  5. {
  6.     int day;
  7.     int month;
  8.     int year;
  9. }date;//结构体名的定义 自定义类型符

  10. typedef struct
  11. {
  12.     int num;
  13.     char name[20];
  14.     date birthday;

  15. }student;//student 等价于 struct 一个没有结构名的结构体
  16. student stu;
  17. student *pstu = &stu;

  18. void InputStudent()
  19. {
  20.     char choice;
  21.     FILE *fp;
  22.     fp = fopen("C:\\Users\\yyp\\Desktop\\stuscore.txt","a+");
  23.     if(fp == NULL)
  24.     {
  25.         printf("Error!\n");
  26.         exit(0);
  27.     }
  28.     printf("Please input num:");
  29.     scanf("%d",&pstu->num);
  30.     printf("Please input name:");
  31.     scanf("%s",pstu->name);
  32.     printf("Please input birthday:");
  33.     scanf("%d%d%d",&pstu->birthday.year,&pstu->birthday.month,&pstu->birthday.day);//输入数据
  34.     fprintf(fp,"%d %s %d-%d-%d\n",//存完换行
  35.     pstu->num,pstu->name,pstu->birthday.year,pstu->birthday.month,pstu->birthday.day);//把数据存txt文件中
  36.     fclose(fp);
  37.     printf("Continue to input? y or n:\n");
  38.     fflush(stdin);
  39.     scanf("%c",&choice);
  40.     if(choice == 'y')
  41.     {
  42.         InputStudent();
  43.     }
  44. }
复制代码


在VScode运行报错
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status

大佬看看
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-3-11 22:00:45 | 显示全部楼层
调用exit()需要include <Windows.h>头文件
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-3-12 08:55:15 From FishC Mobile | 显示全部楼层
shshabc 发表于 2021-3-11 22:00
调用exit()需要include 头文件

不用的,stdlib.h就可以了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-3-12 10:03:14 | 显示全部楼层
你的main函数入口呢?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-3-12 10:37:13 | 显示全部楼层
人中仙 发表于 2021-3-12 10:03
你的main函数入口呢?

看看我另一个 这个不完整
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-30 21:12

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表