马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct
{
int day;
int month;
int year;
}date;//结构体名的定义 自定义类型符
typedef struct
{
int num;
char name[20];
date birthday;
}student;//student 等价于 struct 一个没有结构名的结构体
student stu;
student *pstu = &stu;
void InputStudent()
{
char choice;
FILE *fp;
fp = fopen("C:\\Users\\yyp\\Desktop\\stuscore.txt","a+");
if(fp == NULL)
{
printf("Error!\n");
exit(0);
}
printf("Please input num:");
scanf("%d",&pstu->num);
printf("Please input name:");
scanf("%s",pstu->name);
printf("Please input birthday:");
scanf("%d%d%d",&pstu->birthday.year,&pstu->birthday.month,&pstu->birthday.day);//输入数据
fprintf(fp,"%d %s %d-%d-%d\n",//存完换行
pstu->num,pstu->name,pstu->birthday.year,pstu->birthday.month,pstu->birthday.day);//把数据存txt文件中
fclose(fp);
printf("Continue to input? y or n:\n");
fflush(stdin);
scanf("%c",&choice);
if(choice == 'y')
{
InputStudent();
}
}
在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
大佬看看 |