Wednesday, July 3, 2019

Library management system project in c++

Library management system project in c++


//Project on Collage Library Management  System
#include<stdio.h>///for input output functions like printf, scanf
#include<stdlib.h>#include<conio.h>)
#include<string.h>
#include<dos.h>
#include<graphics.h>
///string operations
#include<conio.h>
#include<iostream.h>

class banner
{
char *str,ch;
public:
banner()
{
str="program to text animation";
}
void alternate();
};
void banner::alternate()
{
int i,j,flag=0,c=10;
strcpy(str,"PROJECT WORK");
for(i=0;!kbhit();i++)
{
//
cleardevice();
/*for clearing part of the screen by drawing lines*/
setfillstyle(SOLID_FILL,BLACK);
bar(50,200,600,240);
//////multicolor banner
if(ch==14)
c=10;
else
c++;
setcolor(c);
//////
settextstyle(TRIPLEX_FONT,HORIZ_DIR,6);
if(flag==0)
{
i++;
if(i==200)
flag=1;
}
else
{
i--;
if(i==0)
flag=0;
}
outtextxy(50+i,200,str);
delay(3);
}
}
void main()
{
int gd=DETECT,gm;
banner obj;
initgraph(&gd,&gm,"c://TC3//BGI");
obj.alternate();
closegraph();
clrscr();
int gdriver=DETECT,gmode,i,j,location,n,c=10;
char *str,ch;
initgraph(&gdriver,&gmode,"C://TC3//BGI");
setcolor(MAGENTA);
setcolor(YELLOW);
setfillstyle(SOLID_FILL,BLUE);
floodfill(50,100,BLUE);
rectangle(10,10,630,470);
settextstyle(7,0,6);
setcolor(WHITE);
outtextxy(20,40,"*******************");
setcolor(WHITE);
outtextxy(160,100,"WELCOME");
setcolor(RED);
outtextxy(230,180,"IN");
setcolor(WHITE);
outtextxy(200,250,"THE");
setcolor(RED);
outtextxy(10,330,"w.w.w onlinestudy.xyz");
setcolor(WHITE);
outtextxy(100,430,"*********************");
sleep(3);
clearviewport();
setcolor(BLACK);
setcolor(YELLOW);
circle(300,280,280);
settextstyle(7,0,6);
outtextxy(150,100,"MADE BY");
outtextxy(30,180,"OnlineStudy.xyz");
settextstyle(7,0,6);
for(i=0;!kbhit();i++)
setfillstyle(SOLID_FILL,BLACK);
bar(10,20,100,20);
if(ch==14)
c=10;
else c++;
setcolor(c);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(100,300,str);
delay(350);
ch=str[0];
n=strlen(str);
location=0;
for(j=location;j<n;j++)
{
str[j]=str[j+1];
}
str[n-1]=ch;
str[n]=NULL;
sleep(3);
clearviewport();
setcolor(BLACK);
setcolor(BLUE);
rectangle(8,8,630,470);
setcolor(BLUE);
settextstyle(7,0,6);
outtextxy(100,80,"WELCOME");
outtextxy(200,150,"TO");
outtextxy(300,200,"COLLEGE");
outtextxy(380,300,"LIBRARY");
sleep(3);
clearviewport();
FILE *fp, *ft;
/// file pointers
char another, choice;
/** structure that represent a student */
struct student
{
char name[40],stream[40],bname[40];
///name of Student
int sem,reg,libno,bno;
/// age of Student
};
struct student e;
/// structure variable creation
char stuname[40];
/// string to store name of the Student
long int recsize;
/// size of each record of Student
/** open the file in binary read and write mode * if the file STU.DAT already exists then it open that file in read write mode * if the file doesn’t exit it simply create a new copy    */
fp = fopen("STU.DAT","rb+");
if(fp == NULL)
{
fp = fopen("STU.DAT","wb+");
if(fp == NULL)
{
printf("Connot open file");
exit(1);
}
}
/// sizeo of each record i.e. size of structure variable e
recsize = sizeof(e);
/// infinite loop continues untile the break statement encounter
while(1)
{
system("cls");
///clear the console window
gotoxy(30,10);
/// move the cursor to postion 30, 10 from top-left corner
printf("1. Add Record");
/// option for add record
gotoxy(30,12);
printf("2. List Records");
/// option for showing existing record
gotoxy(30,14);
printf("3. Modify Records");
/// option for editing record
gotoxy(30,16);
printf("4. Delete Records");
/// option for deleting record
gotoxy(30,18);
printf("5. Exit");
/// exit from the program
gotoxy(30,20);
printf("Your Choice: ");/// enter the choice 1, 2, 3, 4, 5
fflush(stdin);/// flush the input buffer
choice  = getche();/// get the input from keyboard
switch(choice)
{
case '1':/// if user press 1
system("cls");
fseek(fp,0,SEEK_END);/// search the file and move cursor to end of the file
/// here 0 indicates moving 0 distance from the end of the file
another = 'y';
while(another == 'y')
{
/// if user want to add another record
printf("\nEnter name: ");
scanf("%s", &e.name);
printf("\nEnter stream: ");
scanf("%s", &e.stream);
printf("\nEnter sem: ");
scanf("%d", &e.sem);
printf("\nEnter registration no: ");
scanf("%d", &e.reg);
printf("\nEnter library card no: ");
scanf("%d", &e.libno);
printf("\nEnter bookname: ");
scanf("%s", &e.bname);
printf("\nEnter book no: ");
scanf("%d", &e.bno);
fwrite(&e,recsize,1,fp);
/// write the record in the file
printf("\nAdd another record(y/n) ");
fflush(stdin);
another = getche();
}
break;
case '2': system("cls");
rewind(fp);
///this moves file cursor to start of the file
printf("STUDENT LIST");
while(fread(&e,recsize,1,fp)==1)
{
/// read the file and fetch the record one record per fetch
printf("\nname=%s \nstream=%s \nsem=%d \nreg=%d \nlibrary card no=%d \nbook name=%s  \nbookno=%d",e.name,e.stream,e.sem,e.reg,e.libno,e.bname,e.bno);
/// print the name, age and basic salary
}
getch();
break;
case '3':
/// if user press 3 then do editing existing record
system("cls");
another = 'y';
while(another == 'y')
{
printf("Enter the student name to modify: ");
scanf("%s", stuname);
rewind(fp);
while(fread(&e,recsize,1,fp)==1)
{
/// fetch all record from file
if(strcmp(e.name,stuname) == 0)
{
///if entered name matches with that in file
printf("\nEnter new entery ");
//  scanf(“%s%d%f”,e.name,&e.age,&e.bs);
printf("enter student name=");
scanf("%s",&e.name);
printf("enter student stream=");
scanf("%s",&e.stream);
printf("enter student sem=");
scanf("%d",&e.sem);
printf("enter student registration no=");
scanf("%d",&e.reg);
printf("enter student Library card no=");
scanf("%d",&e.libno);
printf("enter student book name=");
scanf("%s",&e.bname);
printf("enter student  book no=");
scanf("%d",&e.bno);
//scanff("\nname=%s \nstream=%s \nsem=%d \nreg=%d \nlibrary card no=%d \n%sbook name= \n%d \n bookno=%d",e.name,e.stream,e.sem,e.reg,e.libno,e.bname,e.bno);
/// print the name, age and basic salary
fseek(fp,-recsize,SEEK_CUR);
/// move the cursor 1 step back from current position
fwrite(&e,recsize,1,fp);
/// override the record
break;
}
}
printf("\nModify another record(y/n)");
fflush(stdin);
another = getche();
}
break;
case '4': system("cls");
another = 'y';
while(another == 'y')
{
printf("\nEnter name of Student to delete: ");
scanf("%s",stuname);
ft = fopen("Temp.dat","wb");
/// create a intermediate file for temporary storage
rewind(fp);
/// move record to starting of file
while(fread(&e,recsize,1,fp) == 1)
{
/// read all records from file
if(strcmp(e.name,stuname) != 0)
{
/// if the entered record match
fwrite(&e,recsize,1,ft);
/// move all records except the one that is to be deleted to temp file
}}
fclose(fp);
fclose(ft);
remove("STU.DAT");
/// remove the orginal file
rename("Temp.dat","STU.DAT");
/// rename the temp file to original file name
fp = fopen("STU.DAT", "rb+");
printf("Delete another record(y/n)");
fflush(stdin);
another = getche();
}
break;
case '5': fclose(fp);
/// close the file
exit(0);
/// exit from the program
}}}

OUTPUT



Library management system project in c++

Library management system project in c++


advanced c project ideasdatabase project for bcabca project topics in vbbca project documentation1000 projects in c with source codepractical c projectsinnovative c projectsc industrial projects,

No comments:

Post a Comment