-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforStudent.c
More file actions
47 lines (37 loc) · 1.13 KB
/
forStudent.c
File metadata and controls
47 lines (37 loc) · 1.13 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include "school_system.h"
extern FILE* fp;
void forStudent(void)
{
int own_id = 0;
char isChange = 0;
STUDENT rec = { 0 };
printf("\n-----Managing System For Student-----\n");
printf("You can search and change your own informations\n");
printf("Enter your ID: ");
scanf("%d", &own_id);
fseek(fp, (own_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("\nYou can only change your phone number, email, address.\n");
printf("Do you want to change your informations?(y/n): ");
scanf(" %c", &isChange);
if(isChange == 'y')
{
printf("\nEnter your new phone number: ");
scanf("%s", rec.phone);
printf("\nEnter your new e-mail: ");
scanf("%s", rec.email);
printf("\nEnter your new address: ");
scanf("%s", rec.addr);
fseek(fp, -(long)sizeof(rec), SEEK_CUR);
fwrite(&rec, sizeof(rec), 1, fp);
}
}
else
{
printf("Not Exist\n");
}
}