You are on page 1of 22

MUSIC LIBRARY

SCHOOL NAME: AIRPORT SCHOOL


AHMEDABAD
STUDENT NAME: KAJAL JASEJA
ROLL NO:1600097
LANGUAGE: C++
INDEX
PARTICULARS PGNO.
ABOUT THE PROJECT 2
HEADER FILES 6
FUNCTIONS 7
CODE 9
OUTPUT 22
1. ABOUT THE PROJECT:
A) REASON: I decided to make a project
related to MUSIC LIBRARY because I have
keen interest in music and wants to make
carrier in music field.
B) WORKING: This project is made In C++
language. The working of the project allows
you to enter all the details regarding the
song you want to include in your library.
The details includes: Song no. ,
Album/Movie of the song, Category of the
song, Singer of the song & language of the
song. You can add, display, search, modify
and delete the songs in this music library.
c) BENEFITS:
i) INFORMATION REGARDING VARIOUS
SONGS: Through this music library , we can
get access to the information of the songs
that are entered in the music library .The
information includes the singers of the
song, movie/album of the song , category
and language of the song.
ii) NOTION OF THE MUSIC: The notion that
music can influence your thoughts, feelings,
and behaviors probably doesn't come as
much of a surprise. If you've ever felt
pumped up while listening to your favorite
fast-paced rock anthem or been moved to
tears by a tender live performance, then
you easily understand the power of music
to impact moods and even inspire action.
iii) CONVENIENT AND EFFICIENT MUSIC
SEARCH: The biggest advantage of our
library is the convenient and efficient music
search and possibilities of searching the
library in many ways.
iv)A FORM OF RELAXATION: There are a
lot of ways to relax but listening to music is
another level of relaxation. Listening to a
music playlist with your set of songs
induces you to calm your nerves.
V) MUSIC BOOSTS OUR ENERGY:
Depending on the mood of the listener,
usually music can make us feel so elated
and happy that we are able to release out
energy through dancing and other sort of
movement just to release that excitement
within us.
D) USES: A playlist is a list of video or audio
files that can be played back on a media
player either sequentially or in
a shuffled order. In its most general form,
an audio playlist is simply a list of songs,
but sometimes a loop. Playlists' uses
include allowing a particular desired
musical atmosphere to be created and
maintained without constant user
interaction, or to allow a variety of different
styles of music be played, again without
maintenance. It can be used in restaurants ,
fitness clubs, parties, etc.
D) DRAWBACK: The biggest drawback of our
music library is that we can only see the
information about the songs which we have
already entered. We cannot hear the audio and
video of the songs.
2. HEADER FILES

HEADER FILES FUNCTION

fstream.h ifstream(),ofstream(),read(),
write(),close(),tellg(),seekg()

process.h exit()

stdio.h remove(),rename(),gets()

conio.h getch(),clrscr()

string.h strcmpi()
3. FUNCTIONS:
i) ifstream(): It represents input stream
and this is used for reading data from files.
ii) ofstream(): It represents output stream
and this is used for writing the data in files.
iii) write():The write() function is used to
write object or record to the file. A record
may be an array, structure or class.
iv) read():The read() function is used to
read object to the file.
v) tellg(): tellg() is used to know where the
get pointer is in a file.
vi) seekg(): It  is used to move the get pointer
to a desired location with respect to a
reference point.
vii) exit(): It is used to exit the program.
viii) remove(): The remove() function deletes a
file from memory.
ix) rename(): The rename() function takes the
name of the file as its argument and the new
name of the file as second argument.
x) strcmpi(): It is used to compare the string
with another string.
4. CODE
class music
{
#include<fstream.h>
#include<process.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>

int sno;
char s_name[50] ,s_category[50], s_movie[50],
singer[50], language[50];
public:
void add()
{
cout<<"\n\t\t\tENTER THE NO. OF THE SONG : ";
cin>>sno;
cout<<"\n\t\t\tENTER SONG NAME:";
gets(s_name);
cout<<"\n\t\t\tENTER ALBUM/SONG MOVIE:";
gets(s_movie);
cout<<"\n\t\t\tENTER SONG CATEGORY:";
gets(s_category);
cout<<"\n\t\t\tENTER NAME OF THE SINGER:";
gets(singer);
cout<<"\n\t\t\tENTER LANGUAGE OF THE
SONG:";
gets(language);
}
void display()
{
cout<<"\nSong No : "<<sno;
cout<<"\nSong Name:"<<s_name;
cout<<"\nAlbum/Movie Name:"<<s_movie;
cout<<"\nCategory of the song:"<<s_category;
cout<<"\nSinger of the song:"<<singer;
cout<<"\nLanguage of the song:"<<language;
cout<<"\n-------------------------\n";
}
char *getname()
{
return s_name;
}
int getsong()
{
return sno;
}
}obj;
void main()
{
int choice;
clrscr();
cout<<"\n\t\t\t....... MAIN MENU...........\t\t\t\t";
cout<<"\n\t\t\t......1.ADD A RECORD........\t\t\t\t";
cout<<"\n\t\t\t......2.DISPLAY THE RECORD..\t\t\t\t";
cout<<"\n\t\t\t......3.SEARCH ANY RECORD ...\t\t\
t\t";
cout<<"\n\t\t\t......4.DELETE ANY RECORD...\t\t\t\t";
cout<<"\n\t\t\t......5.MODIFY THE RECORD . . .
\ t \ t \t\t";
cout<<"\n\t\t\t......6.EXIT................\t\t\t\t";
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>choice;
if(choice==1)
{
ofstream off;
off.open("RECORD.dat",ios::binary|
ios::app);
char ch='Y';
while(ch=='Y')
{
obj.add();
off.write((char*)&obj,sizeof(obj));
cout<<"\nSONG ADDED SUCCESSFULLY";
cout<<"\nWANT TO ENTER MORE RECORDS
Y/N";
cin>>ch;
}
off.close();
getch();
}
else if(choice==2)
{
clrscr();
ifstream iff("RECORD.dat",ios::in|ios::binary);
cout<<"\nYOUR PLAYLIST : ";
while(!iff.eof())
{
iff.read((char*)&obj,sizeof(obj));
obj.display();
}
iff.close();
getch();
}
else if(choice==3)
{
char name[50];
int count=0;
ifstream iff("RECORD.dat",ios::in|ios::binary);
cout<<"\nENTER THE NAME OF THE SONG YOU
WANT TO SEARCH : ";
gets(name);
while(!iff.eof())
{
iff.read((char*)&obj,sizeof(obj));
if(strcmpi(name,obj.getname())==0)
{
obj.display();
count++;
cout<<"\nSONG DETAILS DISPLAYED.";
}
}

if(count==0)
{
cout<<"\nSONG NOT FOUND";
}

iff.close();
getch();
}
else if(choice==4)
{

int no,count=0;
ifstream iff("RECORD.dat",ios::in|ios::binary);
ofstream off("TEMP.dat",ios::app|ios::binary);
cout<<"\nENTER THE No. OF THE SONG YOU
WANT TO DELETE : ";
cin>>no;
while(!iff.eof())
{
iff.read((char*)&obj,sizeof(obj));
if(no!=obj.getsong())
{
off.write((char*)&obj,sizeof(obj));
}
else
{
cout<<"\NSONG DELETED";
obj.display();
count++;
}
}
if(count==0)
{
cout<<"\nSONG NOT FOUND";
}
iff.close();
off.close();
remove("RECORD.dat");
rename("TEMP.dat","RECORD.dat");
getch();
}
else if(choice==5)
{
int no;
int flag=0;
long pos;
fstream off; off.open("RECORD.dat",ios::binary|
ios::out|ios::in);
cout<<"\nENTER THE No. OF THE SONG YOU
WANT TO MODIFY RECORD OF : \n";
cin>>no;
while(off.read((char*)&obj,sizeof(obj)))
{

pos=off.tellg();
if(obj.getsong()==no)
{
off.seekg(pos-sizeof(obj));
cout<<"\nEnter new details : \n";
obj.add();
flag++;

off.write((char*)&obj,sizeof(obj));

}
off.close();
if(flag==0)
{
cout<<"\nSONG NOT FOUND";
}
else
{
cout<<"\nRECORD MODIFIED";
}
getch();
}
else if(choice==6)
{
exit(0);
}
}

You might also like