#include<stdio.h> #include<stdlib.h> struct student{ char sno[10]; char stele[15]; char sname[20]; int score; int age; }; int main() { student class3[31]; scanf("%s%s%s%d%d",&class3[0].sno,&class3[0].sname,&class3[0].stele,&class3[0].age,&class3[0].score); printf("%s %s %s %d %d",class3[0].sno,class3[0].sname,class3[0].stele,class3[0].age,class3[0].score); return 0; }
#include<stdio.h>//将input.txt文件中信息复制到output.txt文件中 #include<stdlib.h> struct student{ char sno[10]; char sname[20]; int age; }; int main() { student class3[31]; FILE*fp=fopen("d:\input.txt","r"); fscanf(fp,"%s%s%d",&class3[0].sno,&class3[0].sname,&class3[0].age); FILE*fs=fopen("d:\output.txt","w"); fprintf(fs,"%s %s %d",class3[0].sno,class3[0].sname,class3[0].age); fclose(fs); return 0; }
#include<stdio.h> struct student{ char sno[10]; char sname[20]; int age; }; student s1; void addStudent() { FILE *fp=fopen("d:\student.txt","a+"); printf("请输入学号:"); scanf("%s",s1.sno); printf("请输入姓名:"); scanf("%s",s1.sname); printf("请输入年龄:"); scanf("%s",&s1.age); fprintf(fp," %s %s %d",s1.sno,s1.sname,s1.age); printf("信息添加成功。 "); } void queryStudent() { printf("query"); } void updateStudent() { printf("update"); } void deleteStudent() { printf("delete"); } void mainmenu() { int choice; printf("学生管理系统 "); printf("1.添加学生信息 "); printf("2.查询学生信息 "); printf("3.修改学生信息 "); printf("4.删除学生信息 "); printf("请选择:"); scanf("%d",&choice); switch(choice) { case 1: addStudent(); break; case 2: queryStudent(); break; case 3: updateStudent(); break; case 4: deleteStudent(); break; default: printf("输入有误,程序退出!"); } } int main() { mainmenu(); }