Pages

Thursday, January 1, 2009

My Birthday Reminder program!

At last I'm done with that birthday reminder program! Here are a few screen shots of my 'software'. :P

The Main Menu


Adding Data:


Checking for birthdays on a particular date:


Clearing data:


Finally, a 'Thank You!':


The code:

#include "stdio.h"
#include "conio.h"
#include "strings.h"
main()
{
void boss(void);
void add(void);
void clear(void);
void bcheck(void);
boss();
system("cls");
printf("\n THANK YOU FOR USING THIS SOFTWARE ");
printf("\n (Press any key to exit)");
getch();
}

void boss(void)
{
int choice;
FILE *bd;
system("cls");
printf("_________________________ PREM'S BIRTHDAY REMINDER ____________________________");
j:printf("\n\nWhat do u want to do?");
printf("\n1. Add Birthday");
printf("\n2. Clear the list");
printf("\n3. Check for a birth date");
printf("\n4. Exit\n");
printf("Enter choice:");
scanf("%d",&choice);
if(choice==1)
add();
if(choice==2)
clear();
if(choice==3)
bcheck();
if(choice!=1 && choice!=2 && choice!=3 && choice!=4)
{printf("\nInvalid choice!\n\n");goto j;}

}

void add()
{
int n;
FILE *bd;
char *name[25],*bday[10];
system("cls");
l:printf("\nAdding a birthday...\n");
printf("Enter the name:");
scanf("%s",name);
printf("Enter the birthday(dd/mm/yyyy):");
scanf("%s",bday);
bd=fopen("Birthday.txt","a");
fprintf(bd,"%s\n%s\n\n",name,bday);
fclose(bd);
printf("_______________________________________________________________________________");
j:printf("\n\nAdd another birthday?\n1 - Yes\n2 - No (Go to main menu) \nEnter your choice:");
scanf("%d",&n);
if(n==2)boss();
if(n==1)
goto l;
if(n!=1 && n!=2)
{printf("\nInvalid choice!");goto j;}
}
void clear(void)
{
int n1,n2;
FILE *cl;
o:system("cls");
printf("\a");
printf("\n WARNING! YOU ARE ABOUT TO CLEAR THE LIST! PROCEED?\n1. Yes\n2. No (Go to main menu)\nEnter choice:");
scanf("%d",&n1);
if(n1==1)
{cl=fopen("Birthday.txt","w");
fclose(cl);
k:printf("\nThe file is empty now! Do you want to add birthday?\n1 - Yes\n2 - No (Go to main menu)\nEnter your choice:");
scanf("%d",&n2);
if(n2==2)boss();
if(n2==1)
add();
if(n2!=1 && n2!=2)
{printf("\nInvalid choice!");goto k;}}
if(n1==2)boss();
if(n1!=1 && n1!=2)
{printf("\nInvalid choice!");goto o;}
}
void bcheck(void)
{
int i=1,flag=0,count=1;
FILE *bd;
char name[50],date[10],input[5];
char *c;
bd = fopen("Birthday.txt","r");
system("cls");
printf("Enter the date:(dd/mm):");
scanf("%s",input);
printf("\nList of people with their birthday falling on %s :",input);
do {
if(i%2!=0)
c = fgets(name,50,bd);
if(i%2==0)
{c=fgets(date,6,bd);
if(!strcmp(input,date))
{flag=1;printf("\n\n%d. %s",count,name);count++;}}
i++;
}while (c != NULL);
if(!flag)
printf("\nNONE!");
fclose(bd);
printf("\n (Press any key to go to main menu)");
getch();
boss();
}

This code was compiled using the compiler - Dev C++, version 4.9.9.2
If you are to use this code, I would recommend the above compiler as some parts of the code may not work on other compilers. You can download Dec C++ compiler here.
(If you want this code but have problems copying from here, contact me at prem.avn@gmail.com)

Note: The file "Birthday.txt" will be created in the directory in which the code is saved.

8 comments:

Please leave your comment here.