-
Notifications
You must be signed in to change notification settings - Fork 0
/
issuebook_function.cpp
116 lines (116 loc) · 2.45 KB
/
issuebook_function.cpp
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
void issuebook()
{
FILE *fp;
FILE *fp1;
FILE *fp2;
char studentid[15],bookid[15];
char ch;
color();
setcolor(BLUE);
settextstyle(7,0,5);
outtextxy(100,30,"ISSUE BOOK PAGE");
gotoxy(30,10);
printf("ENTER STUDDENT ID : ");
fflush(stdin);
scanf("%s",&studentid);
fp1=fopen("student.txt","rb");
if(fp1==NULL)
{
printf("Can't open student file!!!");
getch();
exit(0);
}
fread(&student,sizeof(student),1,fp1);
while(!feof(fp1))
{
if((strcmp(studentid,student.id))==0)
{
fclose(fp1);
goto out2;
}
fread(&student,sizeof(student),1,fp1);
}
fclose(fp1);
gotoxy(25,16);
printf("THIS STUDENT ID HAS NOT CREATED YET");
gotoxy(40,18);
getch();
studentid1();
out2 :
gotoxy(30,12);
printf("ENTER BOOK ID : ");
fflush(stdin);
scanf("%s",&bookid);
fp2=fopen("book.txt","rb");
if(fp2==NULL)
{
printf("Can't open book file!!!");
getch();
exit(0);
}
fread(&books,sizeof(books),1,fp2);
while(!feof(fp2))
{
if((strcmp(bookid,books.id))==0)
{
fclose(fp2);
goto out1;
}
fread(&books,sizeof(books),1,fp2);
}
fclose(fp2);
gotoxy(25,16);
printf("THIS BOOK ID HAS NOT CREATED YET");
gotoxy(40,18);
getch();
studentid1();
out1:
fp=fopen("isbook.txt","rb");
fread(&st1,sizeof(st1),1,fp);
while(!feof(fp))
{
if(((strcmp(st1.bookid,bookid))==0)&&((strcmp(st1.studentid,studentid))==0))
{
gotoxy(25,16);
printf("YOU HAVE ALREADY ISSUED THIS BOOK");
gotoxy(40,18);
getch();
studentid1();
}
fread(&st1,sizeof(st1),1,fp);
}
fclose(fp);
gotoxy(30,14);
printf("ENTER DATE(DD MM YYYY) : ");
fflush(stdin);
scanf("%d %d %d",&st1.date,&st1.month,&st1.year);
gotoxy(25,18);
printf("PRESS I FOR ISSUE THIS BOOK : ");
fflush(stdin);
scanf("%s",&ch);
if(ch=='i'||ch=='I')
{
strcpy(st1.studentid,studentid);
strcpy(st1.bookid,bookid);
fp=fopen("isbook.txt","ab");
if(fp==NULL)
{
printf("Can't open file!!");
getch();
exit(0);
}
fwrite(&st1,sizeof(st1),1,fp);
gotoxy(40,20);
printf("ISSUED");
gotoxy(43,22);
fclose(fp);
}
else
{
gotoxy(40,20);
printf("NOT ISSUED");
gotoxy(43,22);
}
getch();
studentid1();
}