C language Project : Dairy Management System in hindi , write a programme for Dairy Management System in c language
Explanation
इस प्रोजेक्ट मे 7 यूजर define function को use किया गया है |जैसे
int password();- इस function का use पासवर्ड को set करने के लिए किया जाता है |
void add_data();- इस function का use किसी नए data को add करने के लिए किया जाता है |
void Display_data();-इस function का use किसी exits data को view करने के लिए किया जाता है|
void modifydata();-इस function का use किसी exits data को modify करने के लिए किया जाता है |
void changePassword();-इस function का use किसी पासवर्ड को change करने के लिए किया जाता है |
void deleteRecord();-इस function का use किसी data को delete करने के लिए किया जाता है
void main();- इस function मे यूजर द्वारा input लेकर , उसके corresponds function को call किया जाता है |इसके अलावा एक structure को भी define किया गया है जिसमे date ,time ,palce और user name आदि मेमेब्र्स है | जिसमे डायरी के लिए महत्वपूर्ण data को store किया जाता है |
void main() मे ,
इस function मे यूजर द्वारा choice को input किया जाता है | जिसे choice मे assign कर दिया जाता है | इस choice variable की value को switch statement मे pass कर दिया जाता है जिससे उस choice के correspond function को call कर दिया जाता है |
अगर यूजर को password को set करना है तब password() को call किया जाता है |
अगर यूजर को data को add करना है तब add_data() को call किया जाता है |
void add_data()
इसमें loop चलाया जाता है जिसमे
1.यूजर द्वारा data को input कर लिए जाता है और इसे structure data type के variable मे store करा देते है |
2.अगर यूजर द्वार और भी data को add करना होता है तब ये loop दुबरा चलता है अय्न्था ये terminate हो जाता है |
void Display_data() मे ,
इस function मे file मे स्थित data को देखने के लिए code को लिखा जाता है | लेकिन इसमें दो प्रकार के view option होते है |
1.पूरा data : इसमें option मे file के सभी data को display किया जाता है |
2.By Time और Date
इस option यूजर द्वारा date और time दोनों input करा लेते है | इसके बाद file मे स्थित data और यूजर द्वारा दिए गये data मे comparsion होता है और date और time मिलने के बाद data को display करा दिया जाता है |
void deleteRecord() ,
इस function मे delete operation को perform करने के लिए दो तरीके होते है :
1.पूरा data : इसमें option मे file के सभी data को delete किया जाता है |
2.By Time और Date
इस option यूजर द्वारा date और time दोनों input करा लेते है | इसके बाद file मे स्थित data और यूजर द्वारा दिए गये data मे comparsion होता है और date और time मिलने के बाद data को delete करा दिया जाता है |
void modifydata() मे ,
इस function मे , यूजर द्वारा date और time दोनों input करा लेते है | इसके बाद file मे स्थित data और यूजर द्वारा दिए गये data मे comparsion होता है और date और time मिलने के बाद data को modify करा दिया जाता है |
void changePassword() मे ,
इस function मे , यूजर के द्वारा नए पासवर्ड को input किया जाता है | जिसे old पासवर्ड से replace किया जाता है |
Source Code
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
int password();
void add_data();
void Display_data();
void modifydata();
void changePassword();
void deleteRecord();
struct data
{
char t[6];
char user_name[30];
char user_place[25];
char time_duration[10];
char content[500];
};
void main()
{
char choice;
printf(“Personal Diary System “);
while(1)
{
printf(“\n\n\t\tMAIN MENU:”);
printf(“\n\n\tADD data\t enter ‘A'”);
printf(“\n\tVIEW data\t enter ‘V’ “);
printf(“\n\t Modify data\t enter ‘M'”);
printf(“\n\tDELETE data\t enter ‘D'”);
printf(“\n\tEDIT Password \t enter ‘P’ “);
printf(“\n\tEXIT\t\t enter ‘E’ “);
printf(“\n\n\tENTER YOUR CHOICE:”);
scanf(“%c”,&choice);
switch(choice)
{
case ‘A’:
add_data();
break;
case ‘V’:
Display_data();
break;
case ‘M’:
modifydata();
break;
case ‘D’:
deleteRecord();
break;
case ‘P’:
changePassword();
break;
case ‘E’:
printf(“\n\n\t\tTHANK YOU FOR USING THE SYSTEM “);
getch();
exit(0);
default:
printf(“\n WRONG CHOICE “);
printf(“\nPRESS ANY KEY TO TRY AGAIN”);
getch();
break;
}
system(“cls”);
}
getch();
}
void adddata( )
{
system(“cls”);
FILE *f ;
char control = ‘Y’ ,t[10];
struct data e ;
char file user_name[15];
int choice;
printf(“\t\t* WELCOME TO THE ADD MENU *”);
printf(“\n\n\t Enter date :[yyyy-mm-dd]:”);
fflush(stdin);
gets(fileuser_name);
f = fopen (fileuser_name, “ab+” ) ;
if ( f == NULL )
{
f=fopen(fileuser_name,”wb+”);
if(f==NULL)
{
printf(“Invalid file Location ! Please Check again.”);
printf(“\n Press any key foe exit”);
getch();
return ;
}
}
while ( control == ‘Y’|| control==’y’ )
{
choice=0;
fflush(stdin);
printf ( “\n\tENTER t:[hh:mm]:”);
scanf(“%s”,t);
rewind(f);
while(fread(&e,sizeof(e),1,f)==1)
{
if(strcmp(e.t,t)==0)
{
printf(“\n\t Data already exits .\n”);
choice=1;
}
}
if(choice==0)
{
strcpy(e.t,t);
printf(“\tENTER user_name:”);
fflush(stdin);
gets(e.user_name);
fflush(stdin);
printf(“\tENTER user_place:”);
gets(e.user_place);
fflush(stdin);
printf(“\tENTER time_duration:”);
gets(e.time_duration);
fflush(stdin);
printf(“\tcontent:”);
gets(e.content);
fwrite ( &e, sizeof ( e ), 1, f ) ;
printf(“\n Data added \n”);
}
fflush ( stdin ) ;
control = getchar( ) ;
}
fclose ( f ) ;
printf(“\n\n\t Press Key For Exit Operation .”);
getch();
}
void viewdata( )
{
FILE *f ;
system(“cls”);
struct data customer ;
char t[6],choice,fileuser_name[14];
int ch;
printf(“\t\t* view Menu *”);
choice=password();
if(choice!=0)
{
return ;
}
do
{
printf(“\n\tEnter date on which you want eo show content:[yyyy-mm-dd]:”);
fflush(stdin);
gets(fileuser_name);
f = fopen ( fileuser_name, “rb” ) ;
if ( f == NULL )
{
printf(“Invalid file Location ! Please Check again.”);
printf(“\n Press any key foe exit”);
return ;
}
system(“cls”);
printf(“\n\t Type of Viewing Style :\n”);
printf(“\n\t1. Contenet of whole day.”);
printf(“\n\t2. content of Time “);
printf(“\n\t\t Enter Choice:”);
scanf(“%d”,&ch);
switch(ch)
{
case 1:
printf(“\n Whole Data for File %s:”,fileuser_name);
while ( fread ( &customer, sizeof ( customer ), 1, f ) == 1 )
{
printf(“\n”);
printf(“\nt: %s”,customer.t);
printf(“\n User name : %s”,customer.user_name);
printf(“\n Place : %s”,customer.user_place);
printf(“\n Time: %s”,customer.time_duration);
printf(“\n Content: %s”,customer.content);
printf(“\n”);
}
break;
case 2:
fflush(stdin);
printf(“\n Enter Time:[hh:mm]:”);
gets(t);
while ( fread ( &customer, sizeof ( customer ), 1, f ) == 1 )
{
if(strcmp(customer.t,t)==0)
{
printf(“\n content:”);
printf(“\nt: %s”,customer.t);
printf(“\n User name : %s”,customer.user_name);
printf(“\n Place: %s”,customer.user_place);
printf(“\n Time: %s”,customer.time_duration);
printf(“\ncontent: %s”,customer.content);
}
}
break;
default:
printf(“\n Typed Wrong Information \n”);
break;
}
printf(“\n\n Do you like to view more content(Y/N) :”);
fflush(stdin);
scanf(“%c”,&choice);
}
while(choice==’Y’||choice==’y’);
fclose ( f ) ;
return ;
}
void modifydata()
{
system(“cls”);
FILE *f ;
struct data customer ;
char t[6],choice,fileuser_name[14];
int num,count=0;
printf(“Editing Menu”);
choice=security();
if(choice!=0)
{
return ;
}
do
{
printf(“\n\t Enter date to be modify :[yyyy-mm-dd]:”);
fflush(stdin);
gets(fileuser_name);
printf(“\n\tENTER t:[hh:mm]:”);
gets(t);
f = fopen ( fileuser_name, “rb+” ) ;
if ( f == NULL )
{
printf(“Invalid file Location ! Please Check again.”);
printf(“\n Press any key foe exit”);
return ;
}while ( fread ( &customer, sizeof ( customer ), 1, f ) == 1 )
{
if(strcmp(customer.t,t)==0)
{
printf(“\n Old content :”);
printf(“\nt: %s”,customer.t);
printf(“\n User Name: %s”,customer.user_name);
printf(“\n Place : %s”,customer.user_place);
printf(“\n Time: %s”,customer.time_duration);
printf(“\ncontent: %s”,customer.content);
printf(“\n\n\t\t Content by which modify “);
printf(“\n1.t.”);
printf(“\n2. User name .”);
printf(“\n3.Palce”);
printf(“\n4. Time .”);
printf(“\n5.content.”);
printf(“\n6. Whole content.”);
printf(“\n7.Go back to main menu .”);
do
{
printf(“\n\t Enter Choice :”);
fflush(stdin);
scanf(“%d”,&num);
fflush(stdin);
switch(num)
{
case 1:
printf(“\nEnter New Data :”);
printf(“\nNEW t:[hh:mm]:”);
gets(customer.t);
break;
case 2:
printf(“\nName of Persaon you meet :”);
gets(customer.user_name);
break;
case 3:
]
printf(“\nPalce where you meet that person :”);
gets(customer.user_place);
break;
case 4:
printf(“\nEnter New Data :”);
printf(“\ntime_duration:”);
gets(customer.time_duration);
break;
case 5:
printf(“Enter New Data :”);
printf(“\ncontent:”);
gets(customer.content);
break;
case 6:
printf(“\n Enter New Data :”);
printf(“\nNEW t:[hh:mm]:”);
gets(customer.t);
printf(“\n New meeting Name:”);
gets(customer.user_name);
printf(“\n New meeting place:”);
gets(customer.user_place);
printf(“\ntime_duration:”);
gets(customer.time_duration);
printf(“\ncontent:”);
gets(customer.content);
break;
case 7:
printf(“\nPress Any Key for Go back \n”);
getch();
return ;
break;
default:
printf(“\n Wrong Input \n”);
break;
}
}
while(num<1||num>8);
fseek(f,-sizeof(customer),SEEK_CUR);
fwrite(&customer,sizeof(customer),1,f);
fseek(f,-sizeof(customer),SEEK_CUR);
fread(&customer,sizeof(customer),1,f);
choice=5;
break;
}
}
if(choice==5)
{
system(“cls”);
printf(“\n\t\t Editing Operation Successfully \n”);
printf(“THE NEW data IS:\n”);
printf(“\nt: %s”,customer.t);
printf(“\n Meet Person name : %s”,customer.user_name);
printf(“\nPlace of the Meet : %s”,customer.user_place);
printf(“\ntime_duration: %s”,customer.time_duration);
printf(“\ncontent: %s”,customer.content);
fclose(f);
printf(“\n\n\t do you change data more ?.(Y/N)”);
scanf(“%c”,&choice);
count++;
}
else
{
printf(“Wrong data “);
printf(“Enter Your choice again(Y/N) : “);
scanf(“%c”,&choice);
}
}
while(choice==’Y’||choice==’y’);
fclose ( f ) ;
if(count==1)
printf(“\n%d File Edited \n”,count);
else if(count>1)
printf(“\n%d File already Edited \n”,count);
else
printf(“\n No file edited \n”);
getch();
}
int Password()
{
char pass[15]= {0},check[15]= {0},ch;
FILE *fp;
int i=0,j;
printf(“:: Password Enter ::”);
printf(“::You Have Only Three Trails ::”);
for(j=0; j<3; j++)
{
i=0;
printf(“\n\n Enter 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′;
fp=fopen(“SE”,”r”);
if (fp==NULL)
{
printf(“\n File does not exits.\n”);
getch();
return 1;
}
else
i=0;
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
{
check[i]=’\0′;
break;
}
check[i]=ch-5;
i++;
}
if(strcmp(pass,check)==0)
{
printf(“\n\n You Put Right Password . Wait For file Response \n”);
return 0;
}
else
{
printf(“\n\n\t Wrong Password \n”);
printf(“\n Access Denied “);
}
}
printf(“\n\n You Entered Wrong Password”);
printf(“\n\n You are not authorized to Access this file ! Sorry “);
getch();
return 1;
}
void changePassword()
{
system(“cls”);
printf(“\n”);
char pass[15]= {0},confirm[15]= {0},ch;
int choice,i,check;
FILE *f;
f=fopen(“SE”,”rb”);
if(f==NULL)
{
f=fopen(“SE”,”wb”);
if(f==NULL)
{
printf(“Error Occured”);
getch();
return ;
}
fclose(f);
printf(“\nSystem Worked Smoothly Now “);
printf(“\nEnter New Password”);
getch();
}
fclose(f);
check=Password();
if(check==1)
{
return ;
}
do
{
if(check==0)
{
i=0;
choice=0;
printf(“\n\n\tEnter 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(“\n\t Enter Confirm 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)
{
f=fopen(“SE”,”wb”);
if(f==NULL)
{
printf(“\n\t\t Error Occurs”);
getch();
return ;
}
i=0;
while(pass[i]!=’\0′)
{
ch=pass[i];
putc(ch+5,f);
i++;
}
putc(EOF,f);
fclose(f);
}
else
{
printf(“\n\t Password Does Not Matched “);
choice=1;
}
}
}
while(choice==1);
printf(“\n\n\t Password Changed Successfully \n\n\t”);
getch();
}
void deleteRecord( )
{
system(“cls”);
FILE *f,*ftr ;
struct data file ;
char fileuser_name[15],control = ‘Y’ ,t[10];;
int choice,check;
printf(“Delete Operation Start “);
check = security();
if(check==1)
{
return ;
}
while ( control == ‘Y’ )
{
printf(“\n\n\t Option For operation .”);
printf(“\n\n\t# Foe Whole data \t\t\t[1]”);
printf(“\n\t# For selected data according to time \t[2]”);
do
{
printf(“\n\t\t Enter Choice:”);
scanf(“%d”,&choice);
switch(choice)
{
case 1:
printf(“\n\t Enter date:[yyyy-mm-dd]:”);
fflush(stdin);
gets(fileuser_name);
f = fopen (fileuser_name, “wb” ) ;
if ( f == NULL )
{
printf(“\n File not exits.”);
getch();
return ;
}
fclose(f);
remove(fileuser_name);
printf(“\n Delete Operation Completed “);
break;
case 2:
printf(“\n\t Enter date:[yyyy-mm-dd]:”);
fflush(stdin);
gets(fileuser_name);
f = fopen (fileuser_name, “rb” ) ;
if ( f == NULL )
{
printf(” File not exits.”);
getch();
return ;
}
ftr=fopen(“temp”,”wb”);
if(ftr==NULL)
{
printf(“Error Occur”);
printf(“\n Press Any Key For Go Back “);
getch();
return ;
}
printf(“\n\t Enter Time :[hh:mm]:”);
fflush(stdin);
gets(t);
while(fread(&file,sizeof(file),1,f)==1)
{
if(strcmp(file.t,t)!=0)
fwrite(&file,sizeof(file),1,ftr);
}
fclose(f);
fclose(ftr);
remove( fileuser_name);
rename(“temp”,fileuser_name);
printf(“\n .”);
break;
default:
printf(“\n\t Wrong Choice”);
break;
}
}
while(choice<1||choice>2);
printf(“\n\t You want to delete .(Y/N):”);
fflush( stdin );
scanf(“%c”,&control);
}
printf(“\n\n\t Please any key for exit “);
getch();
}
हिंदी माध्यम नोट्स
Class 6
Hindi social science science maths English
Class 7
Hindi social science science maths English
Class 8
Hindi social science science maths English
Class 9
Hindi social science science Maths English
Class 10
Hindi Social science science Maths English
Class 11
Hindi sociology physics physical education maths english economics geography History
chemistry business studies biology accountancy political science
Class 12
Hindi physics physical education maths english economics
chemistry business studies biology accountancy Political science History sociology
English medium Notes
Class 6
Hindi social science science maths English
Class 7
Hindi social science science maths English
Class 8
Hindi social science science maths English
Class 9
Hindi social science science Maths English
Class 10
Hindi Social science science Maths English
Class 11
Hindi physics physical education maths entrepreneurship english economics
chemistry business studies biology accountancy
Class 12
Hindi physics physical education maths entrepreneurship english economics