SlideShare une entreprise Scribd logo
1  sur  57
Télécharger pour lire hors ligne
PASSWORD PROTECTED
PERSONAL DIARY
SHARDA SHARAN
REG. NO. - 1015574
NIPS College of IT & Management
INDEXING
 BACKGROUND
 GENERAL THEORY
 ALGORITHM
 OUTPUT
 DISUSSION
 SUMMARY
 REFRENCE
Background
For technical students, the most important factor to measure their ability and skill is their
practical performance rather than their theoretical knowledge. Considering this fact, this
mini-project is included in our lab assignment to prepare a project using C language in
order to develop their practical ability to develop programs and software using c
programming language.
In this project our project topic PERSONAL DAIRY SYSTEM .In this programm stores
the data related about book record in any dairy .So this program can be used as personal
dairy system.
To build the project, it took us nearly one week. The project required vast knowledge of
use of structure and data file which are two important and complex features of C
programming language. We got help from senior student and teachers in lab. Rest, we
consulted various books on c programming that turned out to be more than useful in gaining
concepts of computer programming.
After gaining the useful concepts, we started the project on modular level. Each of our team
members shared equal load by writing different parts of the program such as different user-
defined functions. We would devote about 2 hour time each day during the college days
and worked throughout the day during holidays.
After the program was successfully written, compiled and tested for syntactic and logical
errors in about one week, we had then to prepare the remaining parts of the project such
as discussion and other theoretical part. This kind of working as a team and working hard
marked the completion of the project.
Objectives:-
1. To learn about different dairy functions included in different header files.
2. To learn about the use of user defined function, structure, array and data file in C.
3. To learn to be able to develop complex programs aimed at solving particular task
in practical field as per users requirements.
4. To be able to work in group as a team sharing different responsibilities
General Theory
This project is based on high level language i.e. c programming. In this project we use
important parts of c programming which are control statement, looping, function, array,
structure, pointer, data file.
C programming language:
c is structured programming based computer programming language was developed by
Dennis Ritchie at Bell laboratories in 1972.Structured programming refers to programming
that produce program with clean flow, clear and a degree of modularity or hierarchical
structure is a simple, contained, versatile, excellent, efficient, fast general purpose
language. It has high degree of language of C is a function oriented additional task
including input and output, graphics, math computation and access to peripheral devices
are placed as library function.
Control Statement:
Logical operation is carried out by several symmetrical or logical statements. There are
two types of control statement based on their function.
Selective structure:
Selective structures are used when we have a number of situations where we need to change
the order of execution of statements based on certain condition. The selective statements
make a decision to take the right path before changing the order of execution. C provides
the following statements for selective structure:
if statements
switch statements
if statements:
The if statement is a powerful decision making statement and it is used to control the flow
of execution of statements. It is a two way statement and is used in conjunction with an
expression.
If statement allows the computer to evaluate the expression first and then on depending
whether the value of the expression is true or false it transfer the control to the particular
statement. At this point of the program has two paths to follow: one for true condition and
other for false condition. The types of if statements are explained below:
Simple if statement:
The simple if statement is used to conditionally excite a block of code based on whether a
test condition is true or false. If the condition is true the block of code is executed, otherwise
it is skipped. The syntax of if statement is given below:
if(test expression
{
statement-block;
}
statement-x;
if else statement
The if else statement extends the idea of the if statement by specifying another section of
code that should be executed only if the condition is false i.e. conditional branching. True-
block statements are to be executed only if the test expression is true and false block
statements to be executed only if the condition is false. The syntax of if else statement is
given below:
if(test expression)
{
true block statement;
}
else
{
false block statement;
}
The switch statement:
c has built in multi way decision statement known as switch. It successively test the value
of an expression against a list of case values (integer or character consonants).when a match
is found the statement associated with that case is executed. The syntax of switch
expression is given below:
switch(expression)
{
case constant-1:
block-1;
break;
case constant-2:
block-2;
break;
………….
………….
case constant-2:
block-n;
break;
default:
default statement;
}
Looping:
Loop caused a section of code to be repeated for a specified number of times or until some
condition holds true. When a condition becomes false, the loop terminates and control
passes to statement below loop. Different types of loops are discussed below with their
major characteristics and syntax used in C:
While loop:
The while loop specifies that a section of code should be executed while a certain condition
holds true. The syntax of while loop is given below:
while(test expression)
{
body of loop;
(
statements block);
}
do while statement:
the do while statement is very similar to while statement. It also specifies that a section of
code should be executed while a certain condition holds true. the difference between while
and do while loop is that while loop test its condition at the top of its loop but do while
loop tests its condition at the bottom of loop. In while loop, if the test condition is false,
the block of code is skipped. Since condition is tested at the bottom of loop in do while
loop, its block of code is always executed at least once. The syntax of do while loop is
given below:
do
{
body of loop
}while (test expression);
For loop:
generally an assignment statement used to set loop control variable. Test expression is a
relational expression that determines when loop exits. Update expression defines how the
loop variable the for loop is used to execute a block of code for a fixed number of
repetitions. Initialization is changes each time when the loop is repeated. The syntax of for
loop is given below:
for(initialization expression;test expression;update expression)
{
body of loop;
}
break statement:
The break statement is used to jump out of loop. The break statement terminates the
execution of the nearest enclosing loop. Control passes to the statement that follows the
terminated statement. in a switch break statement causes the program to execute the next
statement after switch.
break;
Function:
Every c program consists of one or functions. Execution of program always begins by
carrying out instruction in main. Function makes program significantly easier to understand
and maintain. A well written function may be reused in multiple programs. Program that
are easier to design, debug and maintain A function is a self contained program segment
that carries out some specific well defined task..
Return statement:
A function may or may not send back any value to the calling function. If it does, it is
through return statement. The called function can only return only one value per call at
most. The syntax of return statement is given below:
Return;
Pointer:
A pointer is a variable that represents the location (rather than value) of a data item, such
as a variable or an array element. Pointers can be used to pass information back and forth
between a function and a reference point. Pointer provides a way to return multiple data
items from a function via function argument. When a pointer variable is declared, the
variable name must be preceded by an aesteric (*).the syntax of a pointer declaration is:
data type *ptar;
Structure:
It is a heterogeneous user defined data type. It is also called constructed data type. It may
contain different data types .Structure can also store non homogenous data type into a
single collection. Structure may contain pointet, arrays, or even other structures other than
the common data types such as int, float, long int etc. A structure provides a means of
grouping variables under a single name for easier handling and identification. It can be
defined as new named types. It is a convenient way of grouping several pieces of related
information together. Complex hierarchies can be created by nesting structures. Structures
may be copied to and assigned. They are also useful in passing groups of logically related
data into structures. The declaration of structures is given below:
struct tag
{
member 1;
member 2;
member n;
};
DATA FILE
When accessing files through C, the first necessity is to have a way to access the files.
For C File I/O that needs to be used is a FILE pointer, which will let the program keep
track of the file being accessed. (Just as the memory address of the file or the location of
the file).
For example:
FILE *fp;
Where, FILE (uppercase letters required) is a special structure that establishes the buffer
area, and ‘fp’ is a pointer variable that indicates the beginning of the buffer area. It is
defined within a system include file, stdio.h. The pointer fp is often referred to as a
stream pointer, or simply a stream.
To open a file we need to use the fopen function, which returns a FILE pointer. Once a
file is opened, we can use the FILE pointer to let the compiler perform input and output
functions on the file.
FILE *fopen(const char *filename, const char *mode);
where, filename is a string that represents the name of the data file.
The modes are as follows:
r - open for reading
w - open for writing (file need not exist)
a - open for appending (file need not exist)
r+ - open for reading and writing, start at beginning
w+ - open for reading and writing (overwrite file)
a+ - open for reading and writing (append if file exists)
Note that it's possible for fopen to fail even if the program is perfectly correct: it might try
to open a file specified by the user, and that file might not exist (or it might be write-
protected). In those cases, fopen will return 0, the NULL pointer.
Here's a simple example of using fopen:
FILE *fp;
fp = fopen(“file.txt”.”r”);
This code will open file.txt for reading in text mode. To open a file in a binary mode we
must add ‘b’ to the end of the mode string; for example, "rb" (for the reading and writing
modes, we can add the b either after the plus sign - "r+b" - or before - "rb+")
To close a function fclose can use the function
fclose(fp);
fclose returns zero if the file is closed successfully.
remove() is used to rename a file and rename() is used to rename an existing file.
int remove(filename)
int rename(old filename, new filename)
Binary I/O
For binary File I/O we use fread and fwrite to read and write into the data file.
The declarations for each are similar:
size_t fread(void *ptr, size_t size_of_elements, size_t number_of_elements, FILE
*a_file);
size_t fwrite(const void *ptr, size_t size_of_elements, size _t number_of_elements, FILE
*a_file);
Both of these functions deal with blocks of memories - usually arrays. Because they
accept pointers, we can also use these functions with other data structures; you can even
write structs to a file or a read struct into memory.
fread takes four arguments. The declaration of a void *ptr; void means that it is a pointer
that can be used for any type variable. The first argument is the name of the array or the
address of the structure you want to write to the file. The second argument is the size of
each element of the array; it is in bytes. For example, if we have an array of characters
and want to read it in one byte, so size_of_elements is one. You can use the sizeof
operator to get the size of the various datatypes; for example, if we have a variable int x;
you can get the size of x with sizeof(x);. This usage works even for structs or arrays. Eg,
if we have a variable of a struct type with the name a_struct, we can use sizeof(a_struct)
to find out how much memory it is taking up.
e.g.,
sizeof(int);
The third argument is simply how many elements we want to read or write; for example,
if we pass a 100 element array, we want to read no more than 100 elements, so we pass in
100.
The final argument is simply the file pointer we've been using. When fread is used, after
being passed an array, fread will read from the file until it has filled the array, and it will
return the number of elements actually read. If the file, for example, is only 30 bytes, but
we try to read 100 bytes, it will return that it read 30 bytes. To check to ensure the end of
file was reached, use the feof function, which accepts a FILE pointer and returns true if
the end of the file has been reached.
fwrite: is similar in usage, except instead of reading into the memory, it writes from
memory into a file.
fseek: Repositions the file pointer of a stream.
Declaration: int fseek(FILE *stream, long offset, int whence);
Remarks: fseek sets the file pointer associated with a stream to a new position.
stream : -Stream whose file pointer fseek sets.
offset: - Difference in bytes between whence (a file pointer position) and new position.
For text mode streams, offset should be 0 or a value returned by ftell.
whence : - One of three SEEK_xxx file pointer locations (0(SET), 1(CUR), or 2(END)).
fseek is used with stream I/O.
rewind is similar to fseek but it can reposition the stream pointer to the beginning
only.
void rewind(stream);
The above statement is equivalent to fseek(stream, 0L, SEEK_SET)
fflush flushes a stream.
int fflush(*stream);
fflush returns 0 if the buffer was successfully flushed. The value 0 is also returned
in cases in which the specified stream has no buffer or is open for reading only. A return
value of EOF indicates an error.
ALGORITHM
1. Start
2. Declare
main( ) function:
Step 1:start.
Step 2:declare variable choice as integer and check as char.
Step 3:personalize the main menu.
Step 4:creat a while loop.
Step 4.1:display menu item and ask to enter choice
Step 4.2:get the value of the choice
Step 4.3:check the value of choice by using switch case and perform the task as
Step 4.3.1:if ch is 1 then call function addrecord ( )
ch is 2 then call function view record( )
ch is 3 then call function editrecord( )
ch is 4 then call function deleterecord( )
ch is 5 then call function editpassword( )
ch is 6 then call function exit( )
Step 5:stop
addrecord( ) function
Step 1:start.
Step 2:declare file pointer f and variables test as char type .
Step 3:open the file in append and write mode
Step 4:if file cannot open then exit
Step 5 else enter the records
Step 6:get the person record
Step 7:write to the file.
Step 8: if want to escape press esc key and goto main menu
Step8.1 else enter other records
Step 9:close that file.
Step 9+.stop.
viewrecord( ) function
Step 1:start.
Step 2:declare file pointer f ,
Step 3:open the file in read mode.
Step 3.1:if the file doesnot exist exit
Step 4 display records
Step 5 for exit press esc & goto main menu.
Step 7:close that file.
Step 8.stop.
deleterecord( ) function
Step 1:start.
Step 2:declare file pointer fp and fptr ,variables as another=‘y’,time[10],filename[15] are
character type,choice ,check as integer type and declare file as structure with
variable,time,name, place, duration and note as character type.
Step 3:call the paswword( ) function.
Step 4:ask user to enter choice(1or2).
Step 4.1:if choice is 1,delete the whole record of the entered date.
Step 4.2:if choice is 2,delete the specific record.
Step 4.2.1:ask the date.
Step 4.2.2 : open file of that date if it exists goto step 4.2.3 otherwise goto
step 4.3.
Step 4.2.3:ask the time from user.
Step 4.2.4 : read file of that time if it exists delete record of that time
otherwise show that entered time is invalid.
Step 4.3: if he wants to delete another record goto step 4 otherwise goto main menu.
Step 5: close that file.
Step 6:stop.
editpassword( ) FUNCTION BODY
Step 1.start
Step 2. declare file pointer fp,pass[15]={0},confirm[15]={0} as character type and
i,check,choice as an integer type.
Srep 3.initialize check=password( )i.e call the function.
Step 4.if check=1,exit and view main menu otherwise goto step 5.
Step 5.get one password from user and store it in variable pass.
Step 6.get the password from the user and store it in variable confirm for confirmation.
Step 7.compare the two string pass and confirm.
Step 7.1.if the value returned is zero(0) then open the file fp and save password in it
and display the message “password is changed“and enter any key to goto
main menu.
Step 7.2.if value returned is not zero(0) then display “the new password doesnot
match” and goto main menu.
Step 8.stop.
editrecord() FUNCTION BODY:
Step1: clear the screen and declare a file pointer, character array as filename and time,
character choice, integer num and count. assign count =0;
Step2: print the statement “WELCOME TO THE EDITING MENU”,
Step3: call the function password,
Step4: if the return value is not equal to zero return back to main,
Step5: otherwise, in the do loop, read the filename and time,
Step6: open the filename in read mode, if file pointer returns zero display error message
and return back to main,
Step7: otherwise, read the file by size of structure and store in it,
Step8: every time it stores, compare the structure’s time variable with time variable,
Step9: if not equal read another structure form the file,
Step10: otherwise, display the structure as old record and ask for the value of num,
Step10.1.If num=1, read the value of time of structure,
Step10.2.If num=2, read the value of name of structure,
Step10.3.If num=3, read the value of place of structure,
Step10.4.If num=4, read the value of duration of structure,
Step10.5.If num=5, read the value of note of structure,
Step10.6.If num=6, read the whole structure,
Step10.7.If num=7, return back to main,
Step10.8.If num= other then 1 to 7, display error message,
Step11: rewind the pointer to the top of that record and write the fresh structure,
Step12: assign choice =5, increase the value of count by one,
Step13: if no similar structure’s time and time are found go out of the loop without
assigning choice =5,
Step14: if choice =5 then read and display the new record,
Step15: read the value of choice,
Step16: if choice= ‘y’ or ‘Y’ then goto step5, otherwise goto step 17,
Step17: display the value of count,
Step18: return back to main,
Step19: end
SOURCE CODE:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
int password();
void addrecord();
void viewrecord();
void editrecord();
void editpassword();
void deleterecord();
struct record
{
char time[6];
char name[30];
char place[25];
char duration[10];
char note[500];
} ;
void main()
{
int ch;
clrscr();
printf("nnt***********************************n");
printf("t*PASSWORD PROTECTED PERSONAL DIARY*n");
printf("t***********************************");
while(1)
{
printf("nnttMAIN MENU:");
printf("nntADD RECORDt[1]");
printf("ntVIEW RECORDt[2]");
printf("ntEDIT RECORDt[3]");
printf("ntDELETE RECORDt[4]");
printf("ntEDIT PASSWORDt[5]");
printf("ntEXITtt[6]");
printf("nntENTER YOUR CHOICE:");
scanf("%d",&ch);
switch(ch)
{
case 1:
addrecord();
break;
case 2:
viewrecord();
break;
case 3:
editrecord();
break;
case 4:
deleterecord();
break;
case 5:
editpassword();
break;
case 6:
printf("nnttTHANK YOU FOR USING THE
SOFTWARE BY:nntTSHARDA SHARAN SAHU...");
getch();
exit(0);
default:
printf("nYOU ENTERED WRONG CHOICE..");
printf("nPRESS ANY KEY TO TRY AGAIN");
getch();
break;
}
system("cls");
}
}
void addrecord( )
{
FILE *fp ;
char another = 'Y' ,time[10];
struct record e ;
char filename[15];
int choice;
system("cls");
printf("nntt***************************n");
printf("tt* WELCOME TO THE ADD MENU *");
printf("ntt***************************nn");
printf("nntENTER DATE OF YOUR RECORD:[yyyy-mm-dd]:");
fflush(stdin);
gets(filename);
fp = fopen (filename, "ab+" ) ;
if ( fp == NULL )
{
fp=fopen(filename,"wb+");
if(fp==NULL)
{
printf("nSYSTEM ERROR...");
printf("nPRESS ANY KEY TO EXIT");
getch();
return ;
}
}
while ( another == 'Y'|| another=='y' )
{
choice=0;
fflush(stdin);
printf ( "ntENTER TIME:[hh:mm]:");
scanf("%s",time);
rewind(fp);
while(fread(&e,sizeof(e),1,fp)==1)
{
if(strcmp(e.time,time)==0)
{
printf("ntTHE RECORD ALREADY EXISTS.n");
choice=1;
}
}
if(choice==0)
{
strcpy(e.time,time);
printf("tENTER NAME:");
fflush(stdin);
gets(e.name);
fflush(stdin);
printf("tENTER PLACE:");
gets(e.place);
fflush(stdin);
printf("tENTER DURATION:");
gets(e.duration);
fflush(stdin);
printf("tNOTE:");
gets(e.note);
fwrite ( &e, sizeof ( e ), 1, fp ) ;
printf("nYOUR RECORD IS ADDED...n");
}
printf ( "ntADD ANOTHER RECORD...(Y/N) " ) ;
fflush ( stdin ) ;
another = getchar( ) ;
}
fclose ( fp ) ;
printf("nntPRESS ANY KEY TO EXIT...");
getch();
}
void viewrecord( )
{
struct record customer ;
char time[6],choice,filename[14];
int ch;
FILE *fpte ;
system("cls");
printf("nntt*******************************n");
printf("tt* HERE IS THE VIEWING MENU *");
printf("ntt*******************************nn");
choice=password();
if(choice!=0)
{
return ;
}
do
{
printf("ntENTER THE DATE OF RECORD TO BE
VIEWED:[yyyy-mm-dd]:");
fflush(stdin);
gets(filename);
fpte = fopen ( filename, "rb" ) ;
if ( fpte == NULL )
{
puts ( "nTHE RECORD DOES NOT EXIST...n" ) ;
printf("PRESS ANY KEY TO EXIT...");
getch();
return ;
}
system("cls");
printf("ntHOW WOULD YOU LIKE TO VIEW:n");
printf("nt1.WHOLE RECORD OF THE DAY.");
printf("nt2.RECORD OF FIX TIME.");
printf("nttENTER YOUR CHOICE:");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("nTHE WHOLE RECORD FOR %s IS:",filename);
while ( fread ( &customer, sizeof ( customer ), 1, fpte ) == 1 )
{
printf("n");
printf("nTIME: %s",customer.time);
printf("nMEETING WITH: %s",customer.name);
printf("nMEETING AT: %s",customer.place);
printf("nDURATION: %s",customer.duration);
printf("nNOTE: %s",customer.note);
printf("n");
}
break;
case 2:
fflush(stdin);
printf("nENTER TIME:[hh:mm]:");
gets(time);
while ( fread ( &customer, sizeof ( customer ), 1, fpte ) == 1 )
{
if(strcmp(customer.time,time)==0)
{
printf("nYOUR RECORD IS:");
printf("nTIME: %s",customer.time);
printf("nMEETING WITH: %s",customer.name);
printf("nMEETING AT: %s",customer.place);
printf("nDUARATION: %s",customer.duration);
printf("nNOTE: %s",customer.note);
}
}
break;
default: printf("nYOU TYPED SOMETHING ELSE...n");
break;
}
printf("nnWOULD YOU LIKE TO CONTINUE VIEWING...(Y/N):");
fflush(stdin);
scanf("%c",&choice);
}while(choice=='Y'||choice=='y');
fclose ( fpte ) ;
return ;
}
void editrecord()
{
FILE *fpte ;
struct record customer ;
char time[6],choice,filename[14];
int num,count=0;
system("cls");
printf("nntt*******************************n");
printf("tt* WELCOME TO THE EDITING MENU *");
printf("ntt*******************************nn");
choice=password();
if(choice!=0)
{
return ;
}
do
{
printf("ntENTER THE DATE OF RECORD TO BE EDITED:[yyyy-
mm-dd]:");
fflush(stdin);
gets(filename);
printf("ntENTER TIME:[hh:mm]:");
gets(time);
fpte = fopen ( filename, "rb+" ) ;
if ( fpte == NULL )
{
printf( "nRECORD DOES NOT EXISTS:" ) ;
printf("nPRESS ANY KEY TO GO BACK");
getch();
return;
}
while ( fread ( &customer, sizeof ( customer ), 1, fpte ) == 1 )
{
if(strcmp(customer.time,time)==0)
{
printf("nYOUR OLD RECORD WAS AS:");
printf("nTIME: %s",customer.time);
printf("nMEETING WITH: %s",customer.name);
printf("nMEETING AT: %s",customer.place);
printf("nDURATION: %s",customer.duration);
printf("nNOTE: %s",customer.note);
printf("nnttWHAT WOULD YOU LIKE TO EDIT..");
printf("n1.TIME.");
printf("n2.MEETING PERSON.");
printf("n3.MEETING PLACE.");
printf("n4.DURATION.");
printf("n5.NOTE.");
printf("n6.WHOLE RECORD.");
printf("n7.GO BACK TO MAIN MENU.");
do
{
printf("ntENTER YOUR CHOICE:");
fflush(stdin);
scanf("%d",&num);
fflush(stdin);
switch(num)
{
case 1: printf("nENTER THE NEW DATA:");
printf("nNEW TIME:[hh:mm]:");
gets(customer.time);
break;
case 2: printf("nENTER THE NEW DATA:");
printf("nNEW MEETING PERSON:");
gets(customer.name);
break;
case 3: printf("nENTER THE NEW DATA:");
printf("nNEW MEETING PLACE:");
gets(customer.place);
break;
case 4: printf("nENTER THE NEW DATA:");
printf("nDURATION:");
gets(customer.duration);
break;
case 5: printf("ENTER THE NEW DATA:");
printf("nNOTE:");
gets(customer.note);
break;
case 6: printf("nENTER THE NEW DATA:");
printf("nNEW TIME:[hh:mm]:");
gets(customer.time);
printf("nNEW MEETING PERSON:");
gets(customer.name);
printf("nNEW MEETING PLACE:");
gets(customer.place);
printf("nDURATION:");
gets(customer.duration);
printf("nNOTE:");
gets(customer.note);
break;
case 7: printf("nPRESS ANY KEY TO GO
BACK...n");
getch();
return ;
//break;
default: printf("nYOU TYPED SOMETHING
ELSE...TRY AGAINn");
break;
}
}while(num<1||num>8);
fseek(fpte,-sizeof(customer),SEEK_CUR);
fwrite(&customer,sizeof(customer),1,fpte);
fseek(fpte,-sizeof(customer),SEEK_CUR);
fread(&customer,sizeof(customer),1,fpte);
choice=5;
break;
}
}
if(choice==5)
{
system("cls");
printf("nttEDITING COMPLETED...n");
printf("--------------------n");
printf("THE NEW RECORD IS:n");
printf("--------------------n");
printf("nTIME: %s",customer.time);
printf("nMEETING WITH: %s",customer.name);
printf("nMEETING AT: %s",customer.place);
printf("nDURATION: %s",customer.duration);
printf("nNOTE: %s",customer.note);
fclose(fpte);
printf("nntWOULD YOU LIKE TO EDIT ANOTHER
RECORD.(Y/N)");
scanf("%c",&choice);
count++;
}
else
{
printf("nTHE RECORD DOES NOT EXIST::n");
printf("nWOULD YOU LIKE TO TRY AGAIN...(Y/N)");
scanf("%c",&choice);
}
}while(choice=='Y'||choice=='y');
fclose ( fpte ) ;
if(count==1)
printf("n%d FILE IS EDITED...n",count);
else if(count>1)
printf("n%d FILES ARE EDITED..n",count);
else
printf("nNO FILES EDITED...n");
printf("tPRESS ENTER TO EXIT EDITING MENU.");
getch();
}
int password()
{
char pass[15]={0},check[15]={0},ch;
FILE *fpp;
int i=0,j;
printf("::FOR SECURITY PURPOSE::");
printf("::ONLY THREE TRIALS ARE ALLOWED::");
for(j=0;j<3;j++)
{
i=0;
printf("nntENTER THE PASSWORD:");
pass[0]=getch();
while(pass[i]!='r')
{
if(pass[i]=='b')
{
i--;
printf("b");
printf(" ");
printf("b");
pass[i]=getch();
}
else
{
printf("*");
i++;
pass[i]=getch();
}
}
pass[i]='0';
fpp=fopen("SE","r");
if (fpp==NULL)
{
printf("nERROR WITH THE SYSTEM FILE...[FILE
MISSING]n");
getch();
return 1;
}
else
i=0;
while(1)
{
ch=fgetc(fpp);
if(ch==EOF)
{
check[i]='0';
break;
}
check[i]=ch-5;
i++;
}
if(strcmp(pass,check)==0)
{
printf("nntACCESS GRANTED...n");
return 0;
}
else
{
printf("nntWRONG PASSWORD..nntACCESS
DENIED...n");
}
}
printf("nnt::YOU ENTERED WRONG PASSWORD::YOU ARE NOT
ALLOWED TO ACCESS ANY FILE::nntPRESS ANY KEY TO GO
BACK...");
getch();
return 1;
}
void editpassword()
{
char pass[15]={0},confirm[15]={0},ch;
int choice,i,check;
FILE *fp;
system("cls");
printf("n");
fp=fopen("SE","rb");
if(fp==NULL)
{
fp=fopen("SE","wb");
if(fp==NULL)
{
printf("SYSTEM ERROR...");
getch();
return ;
}
fclose(fp);
printf("nSYSTEM RESTORED...nYOUR PASSWORD IS 'ENTER'n
PRESS ENTER TO CHANGE PASSWORDnn");
getch();
}
fclose(fp);
check=password();
if(check==1)
{
return ;
}
do
{
if(check==0)
{
i=0;
choice=0;
printf("nntENTER THE NEW PASSWORD:");
fflush(stdin);
pass[0]=getch();
while(pass[i]!='r')
{
if(pass[i]=='b')
{
i--;
printf("b");
printf(" ");
printf("b");
pass[i]=getch();
}
else
{
printf("*");
i++;
pass[i]=getch();
}
}
pass[i]='0';
i=0;
printf("ntCONFIRM PASSWORD:");
confirm[0]=getch();
while(confirm[i]!='r')
{
if(confirm[i]=='b')
{
i--;
printf("b");
printf(" ");
printf("b");
confirm[i]=getch();
}
else
{
printf("*");
i++;
confirm[i]=getch();
}
}
confirm[i]='0';
if(strcmp(pass,confirm)==0)
{
fp=fopen("SE","wb");
if(fp==NULL)
{
printf("nttSYSTEM ERROR");
getch();
return ;
}
i=0;
while(pass[i]!='0')
{
ch=pass[i];
putc(ch+5,fp);
i++;
}
putc(EOF,fp);
fclose(fp);
}
else
{
printf("ntTHE NEW PASSWORD DOES NOT MATCH.");
choice=1;
}
}
}while(choice==1);
printf("nntPASSWORD CHANGED...nntPRESS ANY KEY TO GO
BACK...");
getch();
}
void deleterecord( )
{
struct record file ;
char filename[15],another = 'Y' ,time[10];
int choice,check;
FILE *fp,*fptr ;
system("cls");
printf("nntt*************************n");
printf("tt* WELCOME TO DELETE MENU*");
printf("ntt*************************nn");
check = password();
if(check==1)
{
return ;
}
while ( another == 'Y' )
{
printf("nntHOW WOULD YOU LIKE TO DELETE.");
printf("nnt#DELETE WHOLE RECORDttt[1]");
printf("nt#DELETE A PARTICULAR RECORD BY TIMEt[2]");
do
{
printf("nttENTER YOU CHOICE:");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("ntENTER THE DATE OF RECORD TO BE
DELETED:[yyyy-mm-dd]:");
fflush(stdin);
gets(filename);
fp = fopen (filename, "wb" ) ;
if ( fp == NULL )
{
printf("nTHE FILE DOES NOT EXISTS");
printf("nPRESS ANY KEY TO GO BACK.");
getch();
return ;
}
fclose(fp);
remove(filename);
printf("nDELETED SUCCESFULLY...");
break;
case 2:
printf("ntENTER THE DATE OF RECORD:[yyyy-mm-dd]:");
fflush(stdin);
gets(filename);
fp = fopen (filename, "rb" ) ;
if ( fp == NULL )
{
printf("nTHE FILE DOES NOT EXISTS");
printf("nPRESS ANY KEY TO GO BACK.");
getch();
return ;
}
fptr=fopen("temp","wb");
if(fptr==NULL)
{
printf("nSYSTEM ERROR");
printf("nPRESS ANY KEY TO GO BACK");
getch();
return ;
}
printf("ntENTER THE TIME OF RECORD TO BE
DELETED:[hh:mm]:");
fflush(stdin);
gets(time);
while(fread(&file,sizeof(file),1,fp)==1)
{
if(strcmp(file.time,time)!=0)
fwrite(&file,sizeof(file),1,fptr);
}
fclose(fp);
fclose(fptr);
remove(filename);
rename("temp",filename);
printf("nDELETED SUCCESFULLY...");
break;
default:
printf("ntYOU ENTERED WRONG CHOICE");
break;
}
}while(choice<1||choice>2);
printf("ntDO YOU LIKE TO DELETE ANOTHER
RECORD.(Y/N):");
fflush(stdin);
scanf("%c",&another);
}
printf("nntPRESS ANY KEY TO EXIT...");
getch();
}
OUTPUT:
DISCUSSION:
During the project compilation, we face different problems on individual handling
of tasks.
The first problem was on the edit menu. The file search was not working properly
due to unarranged stored structure on file. This was solved by going step to step
debugging. Another problem was with view menu. The specific viewing of a record
by time was not working; it was also the same search problem. This was solved by
group discussion. Another problem was with confirming password option; the
function was not working properly. Password change function was a challenge to us.
Searching different books and surfing internet at last kept us with solution. So
solving through group effort was proved to be more efficient.
In this way, we completed our project successfully.
SUMMARY
Our main aim in this program is to prepare book record in library .The class modules
and problems through done on the computers itself were much theoretical than
practical because they were unable to teach us there application in our daily life.
The mini project on the other hand not only taught us practical use of program but
also helped us in gaining skills like co-ordination, leadership, management of time,
planning, foresights, etc. Above all it taught us that we could do something useful
with c-programming. It gave taste of being a programmer which will very useful in
our future.
Thus we can predict that we succeeded on our aim .The problems we faced make us
more confident in C language.
Refrence
Balagurusamy .E., Programming In ANSI C, the Tata McGraw-Hill
Companies, 8th Edition, 2008.
Kanetkar Yashavant, Let Us C, BPB Publication, 9th Edition, 2009.
Gottfriend, Baryon S, Schaum’s outlines Programming With C, the Tata
McGraw-Hill, 2007.
www.google.com
www.sourcecodesworld.com
www.cprogramming.com

Contenu connexe

Tendances

Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language CourseVivek chan
 
Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarSivakumar R D .
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteachingeteaching
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator OverloadingNilesh Dalvi
 
C language industrial training report
C language industrial training reportC language industrial training report
C language industrial training reportRaushan Pandey
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionrohit kumar
 
Functions in c language
Functions in c language Functions in c language
Functions in c language tanmaymodi4
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams Ahmed Farag
 
Library Management System Project in C
Library Management System Project in CLibrary Management System Project in C
Library Management System Project in Ccodewithc
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)Ritika Sharma
 
FUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdfFUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdfRITHIKA R S
 
Friend function
Friend functionFriend function
Friend functionzindadili
 
A c program of Phonebook application
A c program of Phonebook applicationA c program of Phonebook application
A c program of Phonebook applicationsvrohith 9
 

Tendances (20)

Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
Structure of C++ - R.D.Sivakumar
Structure of C++ - R.D.SivakumarStructure of C++ - R.D.Sivakumar
Structure of C++ - R.D.Sivakumar
 
class and objects
class and objectsclass and objects
class and objects
 
basics of C and c++ by eteaching
basics of C and c++ by eteachingbasics of C and c++ by eteaching
basics of C and c++ by eteaching
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Interface
InterfaceInterface
Interface
 
C language industrial training report
C language industrial training reportC language industrial training report
C language industrial training report
 
Uploading a file with php
Uploading a file with phpUploading a file with php
Uploading a file with php
 
Let us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solutionLet us c(by yashwant kanetkar) chapter 2 solution
Let us c(by yashwant kanetkar) chapter 2 solution
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
Library Management System Project in C
Library Management System Project in CLibrary Management System Project in C
Library Management System Project in C
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
FUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdfFUNCTIONS IN C PROGRAMMING.pdf
FUNCTIONS IN C PROGRAMMING.pdf
 
Friend function
Friend functionFriend function
Friend function
 
Project report
Project reportProject report
Project report
 
A c program of Phonebook application
A c program of Phonebook applicationA c program of Phonebook application
A c program of Phonebook application
 
File in c
File in cFile in c
File in c
 

En vedette

Operation manualvrv iv
Operation manualvrv ivOperation manualvrv iv
Operation manualvrv ivngo hoang duy
 
Update Credential R&R_14.12.2016 Last Final
Update Credential R&R_14.12.2016 Last FinalUpdate Credential R&R_14.12.2016 Last Final
Update Credential R&R_14.12.2016 Last Finaltagul islam
 
Internship at Birla Sun Life Insurance Company
Internship at Birla Sun Life Insurance CompanyInternship at Birla Sun Life Insurance Company
Internship at Birla Sun Life Insurance CompanyVamsi bodavula
 
Escenaris d'ús
Escenaris d'úsEscenaris d'ús
Escenaris d'úsEva Durall
 
ТЕСТ «ІГРОВА КІМНАТА»
ТЕСТ «ІГРОВА КІМНАТА» ТЕСТ «ІГРОВА КІМНАТА»
ТЕСТ «ІГРОВА КІМНАТА» Anhelina Mytsura
 
Datastax enterprise presentation
Datastax enterprise presentationDatastax enterprise presentation
Datastax enterprise presentationDuyhai Doan
 
МЕТОДИЧНІ РЕКОМЕНДАЦІї ДЛЯ ФОРМУВАННЯ ПЕДАГОГІЧНОї КУЛЬТУРИ БАТЬКІВ В ДНЗ
МЕТОДИЧНІ РЕКОМЕНДАЦІї ДЛЯ ФОРМУВАННЯ ПЕДАГОГІЧНОї КУЛЬТУРИ БАТЬКІВ В ДНЗМЕТОДИЧНІ РЕКОМЕНДАЦІї ДЛЯ ФОРМУВАННЯ ПЕДАГОГІЧНОї КУЛЬТУРИ БАТЬКІВ В ДНЗ
МЕТОДИЧНІ РЕКОМЕНДАЦІї ДЛЯ ФОРМУВАННЯ ПЕДАГОГІЧНОї КУЛЬТУРИ БАТЬКІВ В ДНЗAnhelina Mytsura
 
Тема: «Математична країна»
Тема: «Математична країна» Тема: «Математична країна»
Тема: «Математична країна» Anhelina Mytsura
 
Callan Corporate Brochure
Callan Corporate BrochureCallan Corporate Brochure
Callan Corporate BrochureKunal Beotra
 

En vedette (10)

Operation manualvrv iv
Operation manualvrv ivOperation manualvrv iv
Operation manualvrv iv
 
Update Credential R&R_14.12.2016 Last Final
Update Credential R&R_14.12.2016 Last FinalUpdate Credential R&R_14.12.2016 Last Final
Update Credential R&R_14.12.2016 Last Final
 
Internship at Birla Sun Life Insurance Company
Internship at Birla Sun Life Insurance CompanyInternship at Birla Sun Life Insurance Company
Internship at Birla Sun Life Insurance Company
 
Escenaris d'ús
Escenaris d'úsEscenaris d'ús
Escenaris d'ús
 
ТЕСТ «ІГРОВА КІМНАТА»
ТЕСТ «ІГРОВА КІМНАТА» ТЕСТ «ІГРОВА КІМНАТА»
ТЕСТ «ІГРОВА КІМНАТА»
 
сітка занять
сітка занятьсітка занять
сітка занять
 
Datastax enterprise presentation
Datastax enterprise presentationDatastax enterprise presentation
Datastax enterprise presentation
 
МЕТОДИЧНІ РЕКОМЕНДАЦІї ДЛЯ ФОРМУВАННЯ ПЕДАГОГІЧНОї КУЛЬТУРИ БАТЬКІВ В ДНЗ
МЕТОДИЧНІ РЕКОМЕНДАЦІї ДЛЯ ФОРМУВАННЯ ПЕДАГОГІЧНОї КУЛЬТУРИ БАТЬКІВ В ДНЗМЕТОДИЧНІ РЕКОМЕНДАЦІї ДЛЯ ФОРМУВАННЯ ПЕДАГОГІЧНОї КУЛЬТУРИ БАТЬКІВ В ДНЗ
МЕТОДИЧНІ РЕКОМЕНДАЦІї ДЛЯ ФОРМУВАННЯ ПЕДАГОГІЧНОї КУЛЬТУРИ БАТЬКІВ В ДНЗ
 
Тема: «Математична країна»
Тема: «Математична країна» Тема: «Математична країна»
Тема: «Математична країна»
 
Callan Corporate Brochure
Callan Corporate BrochureCallan Corporate Brochure
Callan Corporate Brochure
 

Similaire à Password protected diary

Contact management system
Contact management systemContact management system
Contact management systemSHARDA SHARAN
 
Book management system
Book management systemBook management system
Book management systemSHARDA SHARAN
 
Basic construction of c
Basic construction of cBasic construction of c
Basic construction of ckinish kumar
 
Library management system
Library management systemLibrary management system
Library management systemSHARDA SHARAN
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement_jenica
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdfvino108206
 
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A ReviewFernando Torres
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer muniryaseen
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
Fundamentalsofprogrammingfinal 121011003536-phpapp02
Fundamentalsofprogrammingfinal 121011003536-phpapp02Fundamentalsofprogrammingfinal 121011003536-phpapp02
Fundamentalsofprogrammingfinal 121011003536-phpapp02thinesonsing
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...NicheTech Com. Solutions Pvt. Ltd.
 
Fundamentals of programming final
Fundamentals of programming finalFundamentals of programming final
Fundamentals of programming finalRicky Recto
 
C programming course material
C programming course materialC programming course material
C programming course materialRanjitha Murthy
 
Fundamentals of programming final santos
Fundamentals of programming final santosFundamentals of programming final santos
Fundamentals of programming final santosAbie Santos
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving TechniquesAshesh R
 
PCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxPCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxprakashvs7
 

Similaire à Password protected diary (20)

Contact management system
Contact management systemContact management system
Contact management system
 
Book management system
Book management systemBook management system
Book management system
 
Basic construction of c
Basic construction of cBasic construction of c
Basic construction of c
 
Library management system
Library management systemLibrary management system
Library management system
 
Training 8051Report
Training 8051ReportTraining 8051Report
Training 8051Report
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
 
GUI Programming in JAVA (Using Netbeans) - A Review
GUI Programming in JAVA (Using Netbeans) -  A ReviewGUI Programming in JAVA (Using Netbeans) -  A Review
GUI Programming in JAVA (Using Netbeans) - A Review
 
Introduction to ‘C’ Language
Introduction to ‘C’ LanguageIntroduction to ‘C’ Language
Introduction to ‘C’ Language
 
over all view programming to computer
over all view programming to computer over all view programming to computer
over all view programming to computer
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Fundamentalsofprogrammingfinal 121011003536-phpapp02
Fundamentalsofprogrammingfinal 121011003536-phpapp02Fundamentalsofprogrammingfinal 121011003536-phpapp02
Fundamentalsofprogrammingfinal 121011003536-phpapp02
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
 
C Language Presentation.pptx
C Language Presentation.pptxC Language Presentation.pptx
C Language Presentation.pptx
 
Technical Interview
Technical InterviewTechnical Interview
Technical Interview
 
Fundamentals of programming final
Fundamentals of programming finalFundamentals of programming final
Fundamentals of programming final
 
C programming course material
C programming course materialC programming course material
C programming course material
 
Fundamentals of programming final santos
Fundamentals of programming final santosFundamentals of programming final santos
Fundamentals of programming final santos
 
Problem Solving Techniques
Problem Solving TechniquesProblem Solving Techniques
Problem Solving Techniques
 
PCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docxPCCF-UNIT 2-1 new.docx
PCCF-UNIT 2-1 new.docx
 

Dernier

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 

Dernier (20)

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 

Password protected diary

  • 1. PASSWORD PROTECTED PERSONAL DIARY SHARDA SHARAN REG. NO. - 1015574 NIPS College of IT & Management
  • 2. INDEXING  BACKGROUND  GENERAL THEORY  ALGORITHM  OUTPUT  DISUSSION  SUMMARY  REFRENCE
  • 3. Background For technical students, the most important factor to measure their ability and skill is their practical performance rather than their theoretical knowledge. Considering this fact, this mini-project is included in our lab assignment to prepare a project using C language in order to develop their practical ability to develop programs and software using c programming language. In this project our project topic PERSONAL DAIRY SYSTEM .In this programm stores the data related about book record in any dairy .So this program can be used as personal dairy system. To build the project, it took us nearly one week. The project required vast knowledge of use of structure and data file which are two important and complex features of C programming language. We got help from senior student and teachers in lab. Rest, we consulted various books on c programming that turned out to be more than useful in gaining concepts of computer programming. After gaining the useful concepts, we started the project on modular level. Each of our team members shared equal load by writing different parts of the program such as different user- defined functions. We would devote about 2 hour time each day during the college days and worked throughout the day during holidays. After the program was successfully written, compiled and tested for syntactic and logical errors in about one week, we had then to prepare the remaining parts of the project such as discussion and other theoretical part. This kind of working as a team and working hard marked the completion of the project. Objectives:- 1. To learn about different dairy functions included in different header files. 2. To learn about the use of user defined function, structure, array and data file in C. 3. To learn to be able to develop complex programs aimed at solving particular task in practical field as per users requirements. 4. To be able to work in group as a team sharing different responsibilities
  • 4. General Theory This project is based on high level language i.e. c programming. In this project we use important parts of c programming which are control statement, looping, function, array, structure, pointer, data file. C programming language: c is structured programming based computer programming language was developed by Dennis Ritchie at Bell laboratories in 1972.Structured programming refers to programming that produce program with clean flow, clear and a degree of modularity or hierarchical structure is a simple, contained, versatile, excellent, efficient, fast general purpose language. It has high degree of language of C is a function oriented additional task including input and output, graphics, math computation and access to peripheral devices are placed as library function. Control Statement: Logical operation is carried out by several symmetrical or logical statements. There are two types of control statement based on their function. Selective structure: Selective structures are used when we have a number of situations where we need to change the order of execution of statements based on certain condition. The selective statements make a decision to take the right path before changing the order of execution. C provides the following statements for selective structure: if statements switch statements if statements: The if statement is a powerful decision making statement and it is used to control the flow of execution of statements. It is a two way statement and is used in conjunction with an expression.
  • 5. If statement allows the computer to evaluate the expression first and then on depending whether the value of the expression is true or false it transfer the control to the particular statement. At this point of the program has two paths to follow: one for true condition and other for false condition. The types of if statements are explained below: Simple if statement: The simple if statement is used to conditionally excite a block of code based on whether a test condition is true or false. If the condition is true the block of code is executed, otherwise it is skipped. The syntax of if statement is given below: if(test expression { statement-block; } statement-x; if else statement The if else statement extends the idea of the if statement by specifying another section of code that should be executed only if the condition is false i.e. conditional branching. True- block statements are to be executed only if the test expression is true and false block statements to be executed only if the condition is false. The syntax of if else statement is given below: if(test expression) { true block statement; } else {
  • 6. false block statement; } The switch statement: c has built in multi way decision statement known as switch. It successively test the value of an expression against a list of case values (integer or character consonants).when a match is found the statement associated with that case is executed. The syntax of switch expression is given below: switch(expression) { case constant-1: block-1; break; case constant-2: block-2; break; …………. …………. case constant-2: block-n; break; default: default statement; }
  • 7. Looping: Loop caused a section of code to be repeated for a specified number of times or until some condition holds true. When a condition becomes false, the loop terminates and control passes to statement below loop. Different types of loops are discussed below with their major characteristics and syntax used in C: While loop: The while loop specifies that a section of code should be executed while a certain condition holds true. The syntax of while loop is given below: while(test expression) { body of loop; ( statements block); } do while statement: the do while statement is very similar to while statement. It also specifies that a section of code should be executed while a certain condition holds true. the difference between while and do while loop is that while loop test its condition at the top of its loop but do while loop tests its condition at the bottom of loop. In while loop, if the test condition is false, the block of code is skipped. Since condition is tested at the bottom of loop in do while loop, its block of code is always executed at least once. The syntax of do while loop is given below: do {
  • 8. body of loop }while (test expression); For loop: generally an assignment statement used to set loop control variable. Test expression is a relational expression that determines when loop exits. Update expression defines how the loop variable the for loop is used to execute a block of code for a fixed number of repetitions. Initialization is changes each time when the loop is repeated. The syntax of for loop is given below: for(initialization expression;test expression;update expression) { body of loop; } break statement: The break statement is used to jump out of loop. The break statement terminates the execution of the nearest enclosing loop. Control passes to the statement that follows the terminated statement. in a switch break statement causes the program to execute the next statement after switch. break; Function: Every c program consists of one or functions. Execution of program always begins by carrying out instruction in main. Function makes program significantly easier to understand and maintain. A well written function may be reused in multiple programs. Program that are easier to design, debug and maintain A function is a self contained program segment that carries out some specific well defined task..
  • 9. Return statement: A function may or may not send back any value to the calling function. If it does, it is through return statement. The called function can only return only one value per call at most. The syntax of return statement is given below: Return; Pointer: A pointer is a variable that represents the location (rather than value) of a data item, such as a variable or an array element. Pointers can be used to pass information back and forth between a function and a reference point. Pointer provides a way to return multiple data items from a function via function argument. When a pointer variable is declared, the variable name must be preceded by an aesteric (*).the syntax of a pointer declaration is: data type *ptar; Structure: It is a heterogeneous user defined data type. It is also called constructed data type. It may contain different data types .Structure can also store non homogenous data type into a single collection. Structure may contain pointet, arrays, or even other structures other than the common data types such as int, float, long int etc. A structure provides a means of grouping variables under a single name for easier handling and identification. It can be defined as new named types. It is a convenient way of grouping several pieces of related information together. Complex hierarchies can be created by nesting structures. Structures may be copied to and assigned. They are also useful in passing groups of logically related data into structures. The declaration of structures is given below: struct tag { member 1; member 2; member n; };
  • 10. DATA FILE When accessing files through C, the first necessity is to have a way to access the files. For C File I/O that needs to be used is a FILE pointer, which will let the program keep track of the file being accessed. (Just as the memory address of the file or the location of the file). For example: FILE *fp; Where, FILE (uppercase letters required) is a special structure that establishes the buffer area, and ‘fp’ is a pointer variable that indicates the beginning of the buffer area. It is defined within a system include file, stdio.h. The pointer fp is often referred to as a stream pointer, or simply a stream. To open a file we need to use the fopen function, which returns a FILE pointer. Once a file is opened, we can use the FILE pointer to let the compiler perform input and output functions on the file. FILE *fopen(const char *filename, const char *mode); where, filename is a string that represents the name of the data file. The modes are as follows: r - open for reading w - open for writing (file need not exist) a - open for appending (file need not exist) r+ - open for reading and writing, start at beginning w+ - open for reading and writing (overwrite file) a+ - open for reading and writing (append if file exists)
  • 11. Note that it's possible for fopen to fail even if the program is perfectly correct: it might try to open a file specified by the user, and that file might not exist (or it might be write- protected). In those cases, fopen will return 0, the NULL pointer. Here's a simple example of using fopen: FILE *fp; fp = fopen(“file.txt”.”r”); This code will open file.txt for reading in text mode. To open a file in a binary mode we must add ‘b’ to the end of the mode string; for example, "rb" (for the reading and writing modes, we can add the b either after the plus sign - "r+b" - or before - "rb+") To close a function fclose can use the function fclose(fp); fclose returns zero if the file is closed successfully. remove() is used to rename a file and rename() is used to rename an existing file. int remove(filename) int rename(old filename, new filename) Binary I/O For binary File I/O we use fread and fwrite to read and write into the data file. The declarations for each are similar:
  • 12. size_t fread(void *ptr, size_t size_of_elements, size_t number_of_elements, FILE *a_file); size_t fwrite(const void *ptr, size_t size_of_elements, size _t number_of_elements, FILE *a_file); Both of these functions deal with blocks of memories - usually arrays. Because they accept pointers, we can also use these functions with other data structures; you can even write structs to a file or a read struct into memory. fread takes four arguments. The declaration of a void *ptr; void means that it is a pointer that can be used for any type variable. The first argument is the name of the array or the address of the structure you want to write to the file. The second argument is the size of each element of the array; it is in bytes. For example, if we have an array of characters and want to read it in one byte, so size_of_elements is one. You can use the sizeof operator to get the size of the various datatypes; for example, if we have a variable int x; you can get the size of x with sizeof(x);. This usage works even for structs or arrays. Eg, if we have a variable of a struct type with the name a_struct, we can use sizeof(a_struct) to find out how much memory it is taking up. e.g., sizeof(int); The third argument is simply how many elements we want to read or write; for example, if we pass a 100 element array, we want to read no more than 100 elements, so we pass in 100. The final argument is simply the file pointer we've been using. When fread is used, after being passed an array, fread will read from the file until it has filled the array, and it will return the number of elements actually read. If the file, for example, is only 30 bytes, but we try to read 100 bytes, it will return that it read 30 bytes. To check to ensure the end of file was reached, use the feof function, which accepts a FILE pointer and returns true if the end of the file has been reached. fwrite: is similar in usage, except instead of reading into the memory, it writes from memory into a file.
  • 13. fseek: Repositions the file pointer of a stream. Declaration: int fseek(FILE *stream, long offset, int whence); Remarks: fseek sets the file pointer associated with a stream to a new position. stream : -Stream whose file pointer fseek sets. offset: - Difference in bytes between whence (a file pointer position) and new position. For text mode streams, offset should be 0 or a value returned by ftell. whence : - One of three SEEK_xxx file pointer locations (0(SET), 1(CUR), or 2(END)). fseek is used with stream I/O. rewind is similar to fseek but it can reposition the stream pointer to the beginning only. void rewind(stream); The above statement is equivalent to fseek(stream, 0L, SEEK_SET) fflush flushes a stream. int fflush(*stream); fflush returns 0 if the buffer was successfully flushed. The value 0 is also returned in cases in which the specified stream has no buffer or is open for reading only. A return value of EOF indicates an error.
  • 14. ALGORITHM 1. Start 2. Declare main( ) function: Step 1:start. Step 2:declare variable choice as integer and check as char. Step 3:personalize the main menu. Step 4:creat a while loop. Step 4.1:display menu item and ask to enter choice Step 4.2:get the value of the choice Step 4.3:check the value of choice by using switch case and perform the task as Step 4.3.1:if ch is 1 then call function addrecord ( ) ch is 2 then call function view record( ) ch is 3 then call function editrecord( ) ch is 4 then call function deleterecord( ) ch is 5 then call function editpassword( ) ch is 6 then call function exit( ) Step 5:stop addrecord( ) function Step 1:start. Step 2:declare file pointer f and variables test as char type . Step 3:open the file in append and write mode Step 4:if file cannot open then exit Step 5 else enter the records Step 6:get the person record
  • 15. Step 7:write to the file. Step 8: if want to escape press esc key and goto main menu Step8.1 else enter other records Step 9:close that file. Step 9+.stop. viewrecord( ) function Step 1:start. Step 2:declare file pointer f , Step 3:open the file in read mode. Step 3.1:if the file doesnot exist exit Step 4 display records Step 5 for exit press esc & goto main menu. Step 7:close that file. Step 8.stop. deleterecord( ) function Step 1:start. Step 2:declare file pointer fp and fptr ,variables as another=‘y’,time[10],filename[15] are character type,choice ,check as integer type and declare file as structure with variable,time,name, place, duration and note as character type. Step 3:call the paswword( ) function. Step 4:ask user to enter choice(1or2). Step 4.1:if choice is 1,delete the whole record of the entered date.
  • 16. Step 4.2:if choice is 2,delete the specific record. Step 4.2.1:ask the date. Step 4.2.2 : open file of that date if it exists goto step 4.2.3 otherwise goto step 4.3. Step 4.2.3:ask the time from user. Step 4.2.4 : read file of that time if it exists delete record of that time otherwise show that entered time is invalid. Step 4.3: if he wants to delete another record goto step 4 otherwise goto main menu. Step 5: close that file. Step 6:stop. editpassword( ) FUNCTION BODY Step 1.start Step 2. declare file pointer fp,pass[15]={0},confirm[15]={0} as character type and i,check,choice as an integer type. Srep 3.initialize check=password( )i.e call the function. Step 4.if check=1,exit and view main menu otherwise goto step 5. Step 5.get one password from user and store it in variable pass. Step 6.get the password from the user and store it in variable confirm for confirmation. Step 7.compare the two string pass and confirm. Step 7.1.if the value returned is zero(0) then open the file fp and save password in it and display the message “password is changed“and enter any key to goto main menu. Step 7.2.if value returned is not zero(0) then display “the new password doesnot match” and goto main menu. Step 8.stop.
  • 17. editrecord() FUNCTION BODY: Step1: clear the screen and declare a file pointer, character array as filename and time, character choice, integer num and count. assign count =0; Step2: print the statement “WELCOME TO THE EDITING MENU”, Step3: call the function password, Step4: if the return value is not equal to zero return back to main, Step5: otherwise, in the do loop, read the filename and time, Step6: open the filename in read mode, if file pointer returns zero display error message and return back to main, Step7: otherwise, read the file by size of structure and store in it, Step8: every time it stores, compare the structure’s time variable with time variable, Step9: if not equal read another structure form the file, Step10: otherwise, display the structure as old record and ask for the value of num, Step10.1.If num=1, read the value of time of structure, Step10.2.If num=2, read the value of name of structure, Step10.3.If num=3, read the value of place of structure, Step10.4.If num=4, read the value of duration of structure, Step10.5.If num=5, read the value of note of structure, Step10.6.If num=6, read the whole structure, Step10.7.If num=7, return back to main, Step10.8.If num= other then 1 to 7, display error message, Step11: rewind the pointer to the top of that record and write the fresh structure, Step12: assign choice =5, increase the value of count by one, Step13: if no similar structure’s time and time are found go out of the loop without assigning choice =5, Step14: if choice =5 then read and display the new record,
  • 18. Step15: read the value of choice, Step16: if choice= ‘y’ or ‘Y’ then goto step5, otherwise goto step 17, Step17: display the value of count, Step18: return back to main, Step19: end
  • 19. SOURCE CODE: #include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> int password(); void addrecord(); void viewrecord(); void editrecord(); void editpassword(); void deleterecord(); struct record { char time[6]; char name[30]; char place[25]; char duration[10]; char note[500]; } ; void main()
  • 20. { int ch; clrscr(); printf("nnt***********************************n"); printf("t*PASSWORD PROTECTED PERSONAL DIARY*n"); printf("t***********************************"); while(1) { printf("nnttMAIN MENU:"); printf("nntADD RECORDt[1]"); printf("ntVIEW RECORDt[2]"); printf("ntEDIT RECORDt[3]"); printf("ntDELETE RECORDt[4]"); printf("ntEDIT PASSWORDt[5]"); printf("ntEXITtt[6]"); printf("nntENTER YOUR CHOICE:"); scanf("%d",&ch); switch(ch) { case 1:
  • 21. addrecord(); break; case 2: viewrecord(); break; case 3: editrecord(); break; case 4: deleterecord(); break; case 5: editpassword(); break; case 6: printf("nnttTHANK YOU FOR USING THE SOFTWARE BY:nntTSHARDA SHARAN SAHU..."); getch(); exit(0);
  • 22. default: printf("nYOU ENTERED WRONG CHOICE.."); printf("nPRESS ANY KEY TO TRY AGAIN"); getch(); break; } system("cls"); } } void addrecord( ) { FILE *fp ; char another = 'Y' ,time[10]; struct record e ; char filename[15]; int choice; system("cls"); printf("nntt***************************n"); printf("tt* WELCOME TO THE ADD MENU *"); printf("ntt***************************nn");
  • 23. printf("nntENTER DATE OF YOUR RECORD:[yyyy-mm-dd]:"); fflush(stdin); gets(filename); fp = fopen (filename, "ab+" ) ; if ( fp == NULL ) { fp=fopen(filename,"wb+"); if(fp==NULL) { printf("nSYSTEM ERROR..."); printf("nPRESS ANY KEY TO EXIT"); getch(); return ; } } while ( another == 'Y'|| another=='y' ) { choice=0; fflush(stdin); printf ( "ntENTER TIME:[hh:mm]:"); scanf("%s",time);
  • 24. rewind(fp); while(fread(&e,sizeof(e),1,fp)==1) { if(strcmp(e.time,time)==0) { printf("ntTHE RECORD ALREADY EXISTS.n"); choice=1; } } if(choice==0) { strcpy(e.time,time); printf("tENTER NAME:"); fflush(stdin); gets(e.name); fflush(stdin); printf("tENTER PLACE:"); gets(e.place); fflush(stdin); printf("tENTER DURATION:"); gets(e.duration); fflush(stdin); printf("tNOTE:");
  • 25. gets(e.note); fwrite ( &e, sizeof ( e ), 1, fp ) ; printf("nYOUR RECORD IS ADDED...n"); } printf ( "ntADD ANOTHER RECORD...(Y/N) " ) ; fflush ( stdin ) ; another = getchar( ) ; } fclose ( fp ) ; printf("nntPRESS ANY KEY TO EXIT..."); getch(); } void viewrecord( ) { struct record customer ; char time[6],choice,filename[14]; int ch; FILE *fpte ; system("cls"); printf("nntt*******************************n");
  • 26. printf("tt* HERE IS THE VIEWING MENU *"); printf("ntt*******************************nn"); choice=password(); if(choice!=0) { return ; } do { printf("ntENTER THE DATE OF RECORD TO BE VIEWED:[yyyy-mm-dd]:"); fflush(stdin); gets(filename); fpte = fopen ( filename, "rb" ) ; if ( fpte == NULL ) { puts ( "nTHE RECORD DOES NOT EXIST...n" ) ; printf("PRESS ANY KEY TO EXIT..."); getch(); return ; } system("cls"); printf("ntHOW WOULD YOU LIKE TO VIEW:n");
  • 27. printf("nt1.WHOLE RECORD OF THE DAY."); printf("nt2.RECORD OF FIX TIME."); printf("nttENTER YOUR CHOICE:"); scanf("%d",&ch); switch(ch) { case 1: printf("nTHE WHOLE RECORD FOR %s IS:",filename); while ( fread ( &customer, sizeof ( customer ), 1, fpte ) == 1 ) { printf("n"); printf("nTIME: %s",customer.time); printf("nMEETING WITH: %s",customer.name); printf("nMEETING AT: %s",customer.place); printf("nDURATION: %s",customer.duration); printf("nNOTE: %s",customer.note); printf("n"); } break; case 2: fflush(stdin); printf("nENTER TIME:[hh:mm]:");
  • 28. gets(time); while ( fread ( &customer, sizeof ( customer ), 1, fpte ) == 1 ) { if(strcmp(customer.time,time)==0) { printf("nYOUR RECORD IS:"); printf("nTIME: %s",customer.time); printf("nMEETING WITH: %s",customer.name); printf("nMEETING AT: %s",customer.place); printf("nDUARATION: %s",customer.duration); printf("nNOTE: %s",customer.note); } } break; default: printf("nYOU TYPED SOMETHING ELSE...n"); break; } printf("nnWOULD YOU LIKE TO CONTINUE VIEWING...(Y/N):"); fflush(stdin); scanf("%c",&choice);
  • 29. }while(choice=='Y'||choice=='y'); fclose ( fpte ) ; return ; } void editrecord() { FILE *fpte ; struct record customer ; char time[6],choice,filename[14]; int num,count=0; system("cls"); printf("nntt*******************************n"); printf("tt* WELCOME TO THE EDITING MENU *"); printf("ntt*******************************nn"); choice=password(); if(choice!=0) { return ; } do { printf("ntENTER THE DATE OF RECORD TO BE EDITED:[yyyy- mm-dd]:"); fflush(stdin);
  • 30. gets(filename); printf("ntENTER TIME:[hh:mm]:"); gets(time); fpte = fopen ( filename, "rb+" ) ; if ( fpte == NULL ) { printf( "nRECORD DOES NOT EXISTS:" ) ; printf("nPRESS ANY KEY TO GO BACK"); getch(); return; } while ( fread ( &customer, sizeof ( customer ), 1, fpte ) == 1 ) { if(strcmp(customer.time,time)==0) { printf("nYOUR OLD RECORD WAS AS:"); printf("nTIME: %s",customer.time); printf("nMEETING WITH: %s",customer.name); printf("nMEETING AT: %s",customer.place); printf("nDURATION: %s",customer.duration); printf("nNOTE: %s",customer.note); printf("nnttWHAT WOULD YOU LIKE TO EDIT.."); printf("n1.TIME.");
  • 31. printf("n2.MEETING PERSON."); printf("n3.MEETING PLACE."); printf("n4.DURATION."); printf("n5.NOTE."); printf("n6.WHOLE RECORD."); printf("n7.GO BACK TO MAIN MENU."); do { printf("ntENTER YOUR CHOICE:"); fflush(stdin); scanf("%d",&num); fflush(stdin); switch(num) { case 1: printf("nENTER THE NEW DATA:"); printf("nNEW TIME:[hh:mm]:"); gets(customer.time); break; case 2: printf("nENTER THE NEW DATA:"); printf("nNEW MEETING PERSON:"); gets(customer.name); break;
  • 32. case 3: printf("nENTER THE NEW DATA:"); printf("nNEW MEETING PLACE:"); gets(customer.place); break; case 4: printf("nENTER THE NEW DATA:"); printf("nDURATION:"); gets(customer.duration); break; case 5: printf("ENTER THE NEW DATA:"); printf("nNOTE:"); gets(customer.note); break; case 6: printf("nENTER THE NEW DATA:"); printf("nNEW TIME:[hh:mm]:"); gets(customer.time); printf("nNEW MEETING PERSON:"); gets(customer.name); printf("nNEW MEETING PLACE:"); gets(customer.place); printf("nDURATION:");
  • 33. gets(customer.duration); printf("nNOTE:"); gets(customer.note); break; case 7: printf("nPRESS ANY KEY TO GO BACK...n"); getch(); return ; //break; default: printf("nYOU TYPED SOMETHING ELSE...TRY AGAINn"); break; } }while(num<1||num>8); fseek(fpte,-sizeof(customer),SEEK_CUR); fwrite(&customer,sizeof(customer),1,fpte); fseek(fpte,-sizeof(customer),SEEK_CUR); fread(&customer,sizeof(customer),1,fpte); choice=5; break; }
  • 34. } if(choice==5) { system("cls"); printf("nttEDITING COMPLETED...n"); printf("--------------------n"); printf("THE NEW RECORD IS:n"); printf("--------------------n"); printf("nTIME: %s",customer.time); printf("nMEETING WITH: %s",customer.name); printf("nMEETING AT: %s",customer.place); printf("nDURATION: %s",customer.duration); printf("nNOTE: %s",customer.note); fclose(fpte); printf("nntWOULD YOU LIKE TO EDIT ANOTHER RECORD.(Y/N)"); scanf("%c",&choice); count++; } else { printf("nTHE RECORD DOES NOT EXIST::n"); printf("nWOULD YOU LIKE TO TRY AGAIN...(Y/N)"); scanf("%c",&choice);
  • 35. } }while(choice=='Y'||choice=='y'); fclose ( fpte ) ; if(count==1) printf("n%d FILE IS EDITED...n",count); else if(count>1) printf("n%d FILES ARE EDITED..n",count); else printf("nNO FILES EDITED...n"); printf("tPRESS ENTER TO EXIT EDITING MENU."); getch(); } int password() { char pass[15]={0},check[15]={0},ch; FILE *fpp; int i=0,j; printf("::FOR SECURITY PURPOSE::"); printf("::ONLY THREE TRIALS ARE ALLOWED::"); for(j=0;j<3;j++) {
  • 36. i=0; printf("nntENTER THE PASSWORD:"); pass[0]=getch(); while(pass[i]!='r') { if(pass[i]=='b') { i--; printf("b"); printf(" "); printf("b"); pass[i]=getch(); } else { printf("*"); i++; pass[i]=getch(); } } pass[i]='0'; fpp=fopen("SE","r"); if (fpp==NULL)
  • 37. { printf("nERROR WITH THE SYSTEM FILE...[FILE MISSING]n"); getch(); return 1; } else i=0; while(1) { ch=fgetc(fpp); if(ch==EOF) { check[i]='0'; break; } check[i]=ch-5; i++; } if(strcmp(pass,check)==0) { printf("nntACCESS GRANTED...n"); return 0; }
  • 38. else { printf("nntWRONG PASSWORD..nntACCESS DENIED...n"); } } printf("nnt::YOU ENTERED WRONG PASSWORD::YOU ARE NOT ALLOWED TO ACCESS ANY FILE::nntPRESS ANY KEY TO GO BACK..."); getch(); return 1; } void editpassword() { char pass[15]={0},confirm[15]={0},ch; int choice,i,check; FILE *fp; system("cls"); printf("n"); fp=fopen("SE","rb"); if(fp==NULL) { fp=fopen("SE","wb"); if(fp==NULL)
  • 39. { printf("SYSTEM ERROR..."); getch(); return ; } fclose(fp); printf("nSYSTEM RESTORED...nYOUR PASSWORD IS 'ENTER'n PRESS ENTER TO CHANGE PASSWORDnn"); getch(); } fclose(fp); check=password(); if(check==1) { return ; } do { if(check==0) { i=0; choice=0; printf("nntENTER THE NEW PASSWORD:"); fflush(stdin);
  • 43. printf("nntPASSWORD CHANGED...nntPRESS ANY KEY TO GO BACK..."); getch(); } void deleterecord( ) { struct record file ; char filename[15],another = 'Y' ,time[10]; int choice,check; FILE *fp,*fptr ; system("cls"); printf("nntt*************************n"); printf("tt* WELCOME TO DELETE MENU*"); printf("ntt*************************nn"); check = password(); if(check==1) { return ; } while ( another == 'Y' ) {
  • 44. printf("nntHOW WOULD YOU LIKE TO DELETE."); printf("nnt#DELETE WHOLE RECORDttt[1]"); printf("nt#DELETE A PARTICULAR RECORD BY TIMEt[2]"); do { printf("nttENTER YOU CHOICE:"); scanf("%d",&choice); switch(choice) { case 1: printf("ntENTER THE DATE OF RECORD TO BE DELETED:[yyyy-mm-dd]:"); fflush(stdin); gets(filename); fp = fopen (filename, "wb" ) ; if ( fp == NULL ) { printf("nTHE FILE DOES NOT EXISTS"); printf("nPRESS ANY KEY TO GO BACK."); getch(); return ; }
  • 45. fclose(fp); remove(filename); printf("nDELETED SUCCESFULLY..."); break; case 2: printf("ntENTER THE DATE OF RECORD:[yyyy-mm-dd]:"); fflush(stdin); gets(filename); fp = fopen (filename, "rb" ) ; if ( fp == NULL ) { printf("nTHE FILE DOES NOT EXISTS"); printf("nPRESS ANY KEY TO GO BACK."); getch(); return ; } fptr=fopen("temp","wb"); if(fptr==NULL) { printf("nSYSTEM ERROR"); printf("nPRESS ANY KEY TO GO BACK");
  • 46. getch(); return ; } printf("ntENTER THE TIME OF RECORD TO BE DELETED:[hh:mm]:"); fflush(stdin); gets(time); while(fread(&file,sizeof(file),1,fp)==1) { if(strcmp(file.time,time)!=0) fwrite(&file,sizeof(file),1,fptr); } fclose(fp); fclose(fptr); remove(filename); rename("temp",filename); printf("nDELETED SUCCESFULLY..."); break; default: printf("ntYOU ENTERED WRONG CHOICE"); break; } }while(choice<1||choice>2);
  • 47. printf("ntDO YOU LIKE TO DELETE ANOTHER RECORD.(Y/N):"); fflush(stdin); scanf("%c",&another); } printf("nntPRESS ANY KEY TO EXIT..."); getch(); }
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55. DISCUSSION: During the project compilation, we face different problems on individual handling of tasks. The first problem was on the edit menu. The file search was not working properly due to unarranged stored structure on file. This was solved by going step to step debugging. Another problem was with view menu. The specific viewing of a record by time was not working; it was also the same search problem. This was solved by group discussion. Another problem was with confirming password option; the function was not working properly. Password change function was a challenge to us. Searching different books and surfing internet at last kept us with solution. So solving through group effort was proved to be more efficient. In this way, we completed our project successfully.
  • 56. SUMMARY Our main aim in this program is to prepare book record in library .The class modules and problems through done on the computers itself were much theoretical than practical because they were unable to teach us there application in our daily life. The mini project on the other hand not only taught us practical use of program but also helped us in gaining skills like co-ordination, leadership, management of time, planning, foresights, etc. Above all it taught us that we could do something useful with c-programming. It gave taste of being a programmer which will very useful in our future. Thus we can predict that we succeeded on our aim .The problems we faced make us more confident in C language.
  • 57. Refrence Balagurusamy .E., Programming In ANSI C, the Tata McGraw-Hill Companies, 8th Edition, 2008. Kanetkar Yashavant, Let Us C, BPB Publication, 9th Edition, 2009. Gottfriend, Baryon S, Schaum’s outlines Programming With C, the Tata McGraw-Hill, 2007. www.google.com www.sourcecodesworld.com www.cprogramming.com