//daily Graphics diary
//Version 1.0
#include
#include
#include
int newuser(void);
int current(int);
void view(void);
void add(void);
void pchanger(int);
struct diary
{
int time,date;
char content[200],name[20];
struct diary *p;
}dy;
void main()
{
FILE *fp,*fp1,*fp2;
int driver=DETECT,mode,j;
int i,c2,password=123,new1,current1,nch;
char c1,gra;
clrscr();
printf("Do You Like Graphics(y/n)\n");
clrscr();
initgraph(&driver,&mode,"L:\\turbocpp\\cga.bgi");
setbkcolor(9);
setcolor(6);
rectangle(350,270,80,230);
for(j=0;j<50;j++)
{
setcolor(j);
circle(550,120,j);
}
settextstyle(4,HORIZ_DIR, 10);
outtext("DIARY");
printf("\t\t\t\tDIARY\t2010\n");
printf("================================================================================");
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\t\tAre You a new user(Y/N) or view file(v)\n\n");
scanf("%c",&c1);
switch(c1)
{
case 'y' :
new1=newuser();
printf("\n\nDo you want to view your diary(1) or add(2) or exit(3)");
scanf("%d",&nch);
if(nch==1)
view();
else if(nch==2)
add();
else
printf("\n\nThank You");
break;
case 'n' :
current1=current(password);
break;
case 'v':
view();
default:
printf("Wrong choice\n\n\n\n");
}
if(current1==1)
printf("Current User Status=Success\t\a\n");
else
printf("Current User Status=Failed\t\a\n");
if(new1==1)
printf("New User Status=Success\t\a\n");
else
printf("New User Status=Failed\t\a\n");
if(current1!=1&&new1!=1)
{
settextstyle(1,HORIZ_DIR, 7);
outtextxy(40,260,"PROGRAM FAILED");
}
else
{
printf("\n\n\n\n\n\n\n\n\a\t\t Program created by SANJAY\n\t\t ~~~~~~~ ~~~~~~~ ~~ ^^^^^^\n\n\n\t\t\t\t\t\t\t Copyright 2010\n\n\n\t\t\t\t\t\t\t All rights reserved");
printf("\n\n================================================================================");
}
getch();
}
int newuser(void)
{
int time,date,t=1;
char name[20],content[500];
FILE *fp;
clrscr();
printf("================================================================================");
printf("\t\t\tWelcome\n\n\nType your name(please type .txt after entering your name\n");
scanf("%s",&name);
printf("\n\nType today's Date\n");
scanf("%d",&date);
printf("\n\nType time(eg 1130)\n");
scanf("%d",&time);
printf("\n\nType content of what happened in ur dairy\n\n");
scanf("%s",&content);
fp=fopen(name,"a+");
fprintf(fp,"\n\n\n\t\t\t\t%s DIARY\n\n\n\nDate-%d\nTime:%d\n\nContent:%s",name,date,time,content);
printf("Successfully written to file");
printf("\n\n================================================================================");
fclose(fp);
return(t);
}
int current(int password)
{
FILE *fpp;
int mt,pchange,pass,i,j,name1[20],time1,date1,content1,t1=1,driver1=DETECT,mode1,auth=1;
clrscr();
initgraph(&driver1,&mode1,"L:\\turbocpp\\cga.bgi");
setbkcolor(14);
//printf("What You want to do? View password(1) or Continue(2)\n\n");
//scanf("%d",pchange);
//if(pchange==1)
//{
//pchanger(password);
//auth=8;
//}
//else
//{
//if(auth==1)
//{
printf("================================================================================");
printf("\nType password");
scanf("%d",&pass);
if(pass==password)
{
printf("\nPassword is correct\n\nType your name to continue.(Type .txt after typing your name)\n");
scanf("%s",&name1);
printf("\nCkecking Name\n\n\nPlease Wait\a\n\n");
fpp=fopen(name1,"a");
if(fpp==NULL)
printf("File cannot be opened");
else if(ferror(fpp)!=0)
printf("An error have occured\n\n");
else if(feof(fpp))
printf("Error\n\n");
else
{
do
{
printf("Do you want to add content(1) or view your diary(2)\n or exit(3)");
scanf("%d",&i);
switch(i)
{
case 1:
add();
break;
case 2:
view();
break;
case 3:
printf("\nbye\n");
break;
default:
{
printf("Wrong Choice");
j=1;
}
}
printf("\n\nPress 1 to exit or 2 to return to menu\n");
scanf("%d",&j);
}
while(j==2);
}
}
fclose(fpp);
printf("\n================================================================================");
return(t1);
return(6);
}
void add()
{
int time2,date2,driver2=DETECT,mode2;
char name2[20],content2[500];
FILE *ffp;
clrscr();
initgraph(&driver2,&mode2,"L:\\turbocpp\\cga.bgi");
setbkcolor(14);
printf("\n================================================================================");
printf("\t\t\t\nWelcome\n\n\nType ur name with .txt at end");
scanf("%s",name2);
printf("\n\nType today's Date");
scanf("%d",&date2);
printf("\n\nType time(eg 1130)");
scanf("%d",&time2);
printf("\n\nType content of what happened in ur dairy\n\n");
scanf("%s",&content2);
ffp=fopen(name2,"a+");
fprintf(ffp,"\n\n\n\t\t\t\t%s DIARY\n\n\nDate-%d\nTime:%d\n\nContent:%s",name2,date2,time2,content2);
printf("Successfully written to file");
fclose(ffp);
printf("\n\n================================================================================");
}
void view()
{
FILE *fg;
int passw=123,passw1,driver3=DETECT,mode3;
char nam[20],v,asd;
clrscr();
initgraph(&driver3,&mode3,"L:\\turbocpp\\cga.bgi");
setbkcolor(14);
printf("\n\n================================================================================");
printf("\n\nWith View Function You can view files\n\n");
printf("\n\nType Password");
scanf("%d",&passw1);
if(passw1!=passw)
printf("Password is incorrect");
else
{
do
{
printf("Type your name with .txt at end\n");
scanf("%s",&nam);
fg=fopen(nam,"r");
while((v=getc(fg))!=EOF)
printf("%c",v);
printf("\n\nDo you want to view again(1)or not(2)\n");
scanf("%d",&asd);
}
while(asd==1);
fclose(fg);
printf("\n\n\nYou have successfully read your diary\n\nBye\a");
printf("\n\n================================================================================");
}
}
void pchanger(int password)
{
FILE *pc;
int key,secret=111;
char pname[20];
clrscr();
printf("Prove That you are authorized by giving your secret ID Number\n\n");
scanf("%d",&key);
printf("\n\nEntering Network...\a...\n\nChecking Your ID..\a...");
if(key!=secret)
printf("You are un authorized\n\nGet Out Now or the Alarm will be switched ON");
else
{
printf("Enter name");
scanf("%s",&pname);
pc=fopen("passviewed.txt","a+");
fprintf(pc,"\t\t\t\tPassword Viewers\n\nName:- %s\t\tID:-%d\n\n",pname,key);
fclose(pc);
printf("\n\n\n%dPASSWORD = %d",password);
}
}
//latest versions will be posting shortly
//Further assistance contact srnassist@gmail.com