#include <stdio.h>struct student{ char number[10]; Char name[4]; Char gender[20]; Char phone[20]; Char dept[20]; int age; int score;}; int main () { return 0;}
#include <stdio.h>struct student{ char number[10]; Char name[20]; int age ; }; int main () { student class3[31]; int i=0,j; FILE *fp=fopen ("G:\\input.txt", "R"); while (!feof (FP)) { fscanf (FP, "%s%s%d", class3[i].number,class3[i].name,&class3[i].age); i++; } Fclose (FP); Fp=fopen ("G:\\output.txt", "w"); for (j=0;j<i;j++) fprintf (FP, "%s %s %d\n", class3[j].number,class3[j].name,class3[j].age); Fclose (FP); return 0;}
#include <stdio.h>struct student{Char number[10]; Char name[20]; int age;}; void Add () {student class3; int i=0,j; Char W; FILE *fp=fopen ("F:\\student.txt", "A +"); printf ("Please enter Name:"); scanf ("%s", Class3.name);p rintf ("Please enter the study number:"); scanf ("%s", Class3.number); printf ("Please enter Age:"); scanf ("%d", &class3.age); fprintf (FP, "%s%s%d\n", class3.number,class3.name,class3.age); printf ("Information added successfully, whether to continue adding student information (y/n)"); scanf ("%s", &w); Do {printf ("Enter name:"); scanf ("%s", Class3.name);p rintf ("Please enter the study number:"); scanf ("%s", Class3.number); printf ("Please enter Age:"); scanf ("%d", &class3.age); fprintf (FP, "%s%s%d\n", class3.number,class3.name,class3.age); printf ("Information added successfully, whether to continue adding student information (y/n)"); scanf ("%s", &w); }while (w== ' Y ');} int main () {printf ("Class three student management system \ n"); printf ("Add student information \ n"); int A; scanf ("%d", &a); if (a==1) add (); return 0;}
In this question, both Y and N have to continue to add student information, and the judgment in the loop of do while seems useless.
160809322 Wang Xiangjun-12 jobs