0% found this document useful (0 votes)
105 views

C++ Final Project

The document describes a criminal records management system project implemented using C++. It includes modules for inputting criminal records to a file, outputting/displaying records, searching by serial number, and deleting records. The project aims to digitize criminal records management for police stations by providing a database instead of using paper records, in order to prevent records from being tampered with or blamed on rats. It discusses the classes and functions used to implement file handling and allow various operations on the criminal records.

Uploaded by

Shreya Kalyan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views

C++ Final Project

The document describes a criminal records management system project implemented using C++. It includes modules for inputting criminal records to a file, outputting/displaying records, searching by serial number, and deleting records. The project aims to digitize criminal records management for police stations by providing a database instead of using paper records, in order to prevent records from being tampered with or blamed on rats. It discusses the classes and functions used to implement file handling and allow various operations on the criminal records.

Uploaded by

Shreya Kalyan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

ACNOWLEDGEMENT

A lot of effort has gone into the making of this project. However,
its completion would not have been possible without the constant
support and motivation of many individuals. We would like to
extend our sincere thanks to them.
We would like to make a special mention of gratitude regarding
our teacher, Ms. S.S.Saranya, who provided us with the
opportunity to do this wonderful project on the topic Criminal
Record Management System. We would also like to thank our
friends and families who were with us at each stage before it all
finally culminated in the project morphing into its current form; a
tedious task, considering the limited time we had.
ABSTRACT

In this era of digitization, still most police station uses the


traditional pen and paper approach while recording criminal
complaints. Although some of the metropolis police station have
stared the use of PC but still the penetration of computers lacks
the depth. It is a bitter fact that some of the influential people
possess the guts to tear off these criminal record complaints.
Then when and if the enquiry is held, the cops go one step
further and put the blame on rats for the menace which is such
an unfortunate thing in our country. In a country where rats are
worshipped by certain section of the community as the vehicle
of Lord Ganesh, it is ironical that they are many a times falsely
accused by the corrupt officials. So, we have implemented the
concept of file handling to create an E-Criminal Records
Database System.
MODULES
CLASSES USED:
1. Criminal – The master class whose object manages the
whole data
MEMBER FUNCTIONS OF CLASS CRIMINAL:
1. input – Inserts data in the file.
2. output - Displays the information stored in the file.
3. rno – Displays the information of a particular record by
identifying its serial number.
4. del – Deletes a particular record.
5. f1 – Compares the rno given by the user and the name
already present in the record and returns
a Boolean answer.
6. getname – Returns the name of the person.
The programming language used is C++ and the IDE used is
TURBO C++ 3.5
SOURCE CODE

#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<process.h>
#include<dos.h>
ifstream fin; //File handling
ofstream fout;
int count=0;
class criminal //Main class
{ int sno,age;
char
name[20],gender,residency[50],fname[20],reason[20];
public:
void input(); //Function for giving the details of the
criminal as input into a file
void output(); //Function for displaying the details of the
//criminal as input from the file
void rno(int x); //Function for searching a particular
//record by giving the rno as input
void del(); // Function for deleting a particular record by
//giving the name as input
int f1(char na[20])
{return strcmpi(name,na);
}

int f2(int x)
{ int a=0;
if(sno==x)
return a;
else
return (a+1);
}
char* getname()
{ return name;
}
} s;
void criminal:: input ()
{ clrscr();
int a=1;
ofstream fout;
if(!fout)
{ cout<<"Cannot be created ";
return;
}
fout.open("input.dat",ios::binary|ios::out); //File opened for
//entering the details
char ch;
do
{ //Details
cout<<"Enter the serial number = ";
cin>>sno;
cout<<"Enter name = ";
gets(name);
cout<<"Enter Father name =";
gets(fname);
cout<<"Enter age = ";
cin>>age;
cout<<"Enter the reason for arrest =";
gets(reason);
cout<<"Enter gender(M/F) = ";
cin>>gender;
while(a==1)
{ if(gender=='m'||gender=='f')
{a=0;
break;
}
else
{ cout<<"Enter correct gender \n";
}
}
cout<<"Enter residency =";
gets(residency);
fout.write((char *)&s,sizeof(s));
cout<<"Do you want to enter more?(Y/N)\n";
cin>>ch;
}while(ch=='Y'||ch=='y');
fout.close(); //File closed after details are recorded
}
void criminal :: output()
{
cout<<"\nSerial number = "<<sno;
cout<<"\nName = "<<name;
cout<<"\nFather's name = "<<fname;
cout<<"\nAge = "<<age;
cout<<"\nReason = "<<reason;
cout<<"\nGender = "<<gender;
cout<<"\nResidency = "<<residency;

void criminal:: rno(int y)


{ int d,f=0;
fin.open("input.dat",ios::binary);
while(fin)
{
fin.read((char*)&s,sizeof(s)); //For reading contents of the file
//after opened
f=s.f2(y);
if(f==0)
{ s.output();
d=1;
break;
}
}
if(d==0)
{ cout<<"Not found";
}
fin.close(); //File closed after searching the required
//record and displaying the output
}
void criminal:: del()
{
fin.open("input.dat",ios::binary|ios::in);
fin.seekg(0); //File cursor pts to the beginning of the file
char x[20];
int b;
char nam[20];
clrscr();
cout<<"Enter the name of the person for whom you
want to delete the data = ";
gets(nam);
int i,ch,flag=0;
fout.open("ABC.dat",ios::binary|ios::app);
//Temporary file created to store the records which do not match
//in input from the user.
fin.seekg(0);
while (fin)
{ fin.read((char*)&s,sizeof(s));
strcpy(x,getname());
if(strcmpi(x,nam)!=0)
{ fout.write((char*)&s,sizeof(s));
flag=1;
}
}
if(flag==1)
cout<<"Record of the person whose name is
"<<nam<<" is succesfully deleted !!!";
for(i=0;i<5;i++)
cout<<"\n";
if(flag==0)
cout<<"Not Found";
fin.close();
fout.close();
remove("input.dat");
rename("ABC.dat","input.dat");
}

void main()
{
clrscr();
int i,n,x,d;
char ch,na[20];
clrscr();
int choice,j;
clrscr();
for(i=0;i<10;i++)
cout<<"\n";
cout<<"\t\t\t\t"<<" "<<"WELCOME!!!!\n\n";
cout<<"\n\t\t\t"<<" "<<"PRESS ANY KEY TO
CONTINUE \n";

getch();
clrscr();
char pass[20],p[20];
strcpy(pass,"shreya"); //Password
for(i=3;i>0;i--)
{
cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\t\tEnter password = \n";
cout<<"\n\n\t\t\t\t";
for(int u=0;u<6;u++)
{p[u] = getch();
if(int(p[u])==8){
cout<<"\b";
u--;
cout<<" ";
cout<<"\b";
}
else
{
cout<<"*";
}
}

p[u]='\0';
clrscr();
if(strcmp(p,pass)==0)
{ cout<<" \t\t\t\t\tCORRECT!!!!!";
break;
}
else
{ if((i-1)!=1)
cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\t You have
"<<i-1<<" chances left ";
else
cout<<"\n\n\n\n\n\n\n\n\n\n\t\t\t You have
"<<"1"<<" chance left ";
}
}
clrscr();
if(i==0)
{ cout<<"Wrong password!!!!!";
exit(0);
}
clrscr();
do
{ clrscr();
for(int c=0;c<40;c++)
cout<<"*-";
cout<<"\t\t\t\tENTER YOUR CHOICE";
cout<<"\n\t1) Input Data\n\t2) Display all \n\t3)
Search by serial number \n\t4) Delete a record \n\t5) Exit\n";
for( c=0;c<40;c++)
cout<<"*-";
cin>>choice;
switch(choice)
{ case 1: s.input();
break;
case 2: fin.seekg(0);
fin.open("input.dat",ios::binary);
while( fin.read((char*)&s,sizeof(s)))
{ s.output();
cout<<"\n\n\n";
}
break;

case 3: cout<<"Enter the serial number =\n";


cin>>x;
s.rno(x);
break;
case 4: s.del();
break;
case 5: exit(0);
default:cout<<"Wrong choice selected\n";

}
cout<<"\nDo you want to go back to the main menu
?(Y/N)\n";
cin>>ch;
} while(ch=='Y'||ch=='y');
getch();
}
//End of Code
SCREEN SHOTS OF OUTPUT

1. WELCOME PAGE

2. AUTHENTICATION
2.a IF PASSWORD IS NOT CORRECT

2.b IF PASSWORD IS CORRECT


3. WHEN OPTION 1 IS CHOSEN

4. WHEN OPTION 2 IS CHOSEN


5. WHEN OPTION 3 IS CHOSEN

6. WHEN OPTION 4 WAS CHOSEN…

AND IF OPTION 2 IS CHOSEN AGAIN


CONCLUSION
The project, E-Criminal Records Database System is platform
provided for safe guarding a database of all the criminals in the
police station.
This project is aimed specifically towards people for those who
prefer virtual reading. This helps to promote awareness among
people to save paper and no cut trees.
This project gave us the opportunity to explore a lot in the fields
of computer science, mainly the C++ Language. It turned out to
be a very challenging, informative and interesting experience for
us; which would have been a lot more difficult if not for the
guidance of my teacher.
REFERENCES
1. www.cppforschool.com/tutorial/Files1.html
2. https://www.tutorialpoint.com>
Cplusplus>C++FilesandStreams
3. https://www.codesdope.com/cpp-file-io/
4. www.csegeek.com/csegeek/view/tutorials/cpp_lang/cpp_fil
e.php

You might also like