-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangeStudent.c
More file actions
32 lines (25 loc) · 895 Bytes
/
changeStudent.c
File metadata and controls
32 lines (25 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include "school_system.h"
extern FILE* fp;
void changeStudent(void)
{
int change_id = 0;
STUDENT rec = { 0 };
printf("\n-----Enter Student ID to change informations-----\n");
scanf("%d", &change_id);
fseek(fp, (change_id - STARTID)*(long)sizeof(rec), SEEK_SET);
if((fread(&rec, sizeof(rec), 1, fp) > 0) && (rec.id != 0))
{
printf("%d %s %s %s %s %s %d %s %s\n", rec.id, rec.name, rec.phone, rec.email,
rec.addr, rec.major, rec.scholar, rec.multimajor, rec.state);
printf("\nEnter changed informations.\nEnter the same, if the information has nothing to change.\n");
scanf("%d %s %s %s %s %s %d %s %s", &rec.id, rec.name, rec.phone, rec.email,
rec.addr, rec.major, &rec.scholar, rec.multimajor, rec.state);
fseek(fp, -(long)sizeof(rec), SEEK_CUR);
fwrite(&rec, sizeof(rec), 1, fp);
}
else
{
printf("Not Exist\n");
}
}