Could u help me with this?
Project Description:
Design and implement a program that acts as a electronic diary for a college student. The diary should be able to add or remove entries in to the diary. It should also be albe to search for entries either by date or title or by categories. All data is the diary should be able to be saved on a file so it can be used again.
A diary entry consis of a ID,DATE,CATEGORY, TITlE,CONTENT.
The ID format consists of a string.
The DATE format shold be as “01-12-2009” or “01/12?2009”
The CATEGORY format consists of a string. Categories include events, anniversaries, birthdays, deadlines, school or other etc.
The TITLE format must be a string (maximum characters 30).
The CONTENT format must be a string (maximum characters 150).
Example of a diray entry:
[100] [06-04-2009] [School] [School Exams] [Study of ITEC111 exams, Meet group for project discussion]
Project Contents:
Implement your project program using C language.
Programs must be able to complile and execute properly;
Program code must cont contain documentation for methods, varibles etc.
Any external files such as “text files” should be packaged with program.
Additonal marks will be given for program GUI or GUI graphics.
Any additional features added on to program such as showing important upcoming items for the week depending on the current etc
Use of arrays should be credited with extra marks.
This is what done so far. I am having problems in the area to remove an entry.
//Project Guren MK II: Flight-Enabled Version
//Category Search Working!!!
#include
#include
#include
#include
#include
#define MenuSpace ” ”
#define LineSkip “\n\n” //Skips 2 Lines
#define Divider “—————————–\n\n”
#define MaxRecNum 100
typedef struct alldata {
char Data_ID [4];
char Data_Date [11];
char Data_Cat [16];
char Data_Title [31];
char Data_Con [151];
} AllData;
AllData InRec [MaxRecNum];
main()
{
int AddRec ();
int SearchCat();
int SearchTitle ();
int SearchDate ();
void GetRec (int, AllData);
int Menu();
int Choice = Menu();
while (Choice != 0)
{
if (Choice == 1)
Choice = AddRec(); //Calls Function “AddRec” to add a record
else if (Choice == 2)
Choice = SearchCat(); // Calls Function “SearchCat” to search via the “Category” Field
else if (Choice == 3)
Choice = SearchTitle ();
else if (Choice == 4)
Choice = SearchDate ();
else if (Choice == 5)
printf (“Function Not Ready”);//Filler Code
else
Choice = Menu();
}
}
int Menu ()
{
int MenuPick;
system (” cls “);
printf (“%s%s———-MAIN MENU———-\n\n”, LineSkip, MenuSpace);
printf (“%s[1] Add Entry\n\n”, MenuSpace);
printf (“%s%s”, MenuSpace, Divider); //Divider
printf (“%s -SEARCH OPTIONS-\n\n”, MenuSpace);
printf (“%s [2] Search by Category\n\n”, MenuSpace);
printf (“%s [3] Search by Title\n\n”, MenuSpace);
printf (“%s [4] Search by Date\n\n”, MenuSpace);
printf (“%s%s”, MenuSpace, Divider); //Divider
printf (“%s[5] DELETE Records\n\n”, MenuSpace);
printf (“%s%s”, MenuSpace, Divider); //Divider
printf (“%s[0] EXIT PRogram\n\n”, MenuSpace);
printf (“%s%s”, MenuSpace, Divider); //Divider
printf (“Select a Number From the List: “);
scanf (“%d”, &MenuPick);
return MenuPick;
}
void DeleteRecord (int Delete, AllData InRec[])
{
char Confirm [10] = “NO”;
system (“cls”);
printf (“\nWARNING: Records that have been Erased CANNOT be recovered!\n”);
printf (“——————————————————-“);
printf (“\n Entry ID : %s\n”, InRec [Delete].Data_ID);
printf (“\n Date of Entry : %s\n”, InRec [Delete].Data_Date);
printf (“\n Category : %s\n”, InRec [Delete].Data_Cat);
printf (“\n Title : %s\n”, InRec [Delete].Data_Title);
printf (“\n Text: \n %s\n”, InRec [Delete].Data_Con);
printf (“——————————————————-\n\n\n”);
printf(“Really DELETE this Record? Type ‘DELETE’ To Confirm\n”);
gets (Confirm);
gets (Confirm);
if (strcmp (Confirm, “DELETE”) == 0)
{
strcpy (InRec [Delete].Data_ID, “@_@”);
strcpy (InRec [Delete].Data_Date, ” “);
strcpy (InRec [Delete].Data_Cat, ” “);
strcpy (InRec [Delete].Data_Title, ” “);
strcpy (InRec [Delete].Data_Con, ” “);
FILE * Data_Output = fopen (“AllRecords.bin”, “wb”);
for (int Count =1; Count <= MaxRecNum; Count ++)
{ if (Count != Delete)
fwrite (&InRec[Count], sizeof (AllData), 2, Data_Output);
}
fclose (Data_Output);
printf ("\n\n
}
}
void GetRec (int Found, AllData InRec[])
{
int Select = 0;
printf (“——————————————————-“);
printf (“\n\n%d Record(s) Found”, Found);
printf (“\n\nWhich Record to Load (Enter 0 to Quit): “);
scanf (“%d”, &Select);
if (Select != 0)
{
system (“cls”);
printf (“——————————————————-“);
printf (“\n Entry ID : %s\n”, InRec [Select].Data_ID);
printf (“\n Date of Entry : %s\n”, InRec [Select].Data_Date);
printf (“\n Category : %s\n”, InRec [Select].Data_Cat);
printf (“\n Title : %s\n”, InRec [Select].Data_Title);
printf (“\n Text: \n %s\n”, InRec [Select].Data_Con);
printf (“——————————————————-\n\n\n”);
printf (“[0] Return to Main Menu\n\n”);
printf (“[9] DELETE THIS RECORD”);
int Option = 0;
printf (“\n\nSelect Option: “);
scanf (“%d”, &Option);
if (Option == 9)
DeleteRecord (Select, InRec);
}
}
int AddRec ()
{
int Current =1;
printf (“\n\n\nEntry Number: “);
gets (InRec [Current].Data_ID);
gets (InRec [Current].Data_ID);
if (strcmp (InRec [Current].Data_ID, “”) == 0)
InRec [Current].Data_ID[0] += ‘?’;
printf (“Date (DD/MM/YYYY): “);
gets (InRec [Current].Data_Date);
if (strcmp (InRec [Current].Data_Date, “”) == 0)
InRec [Current].Data_Date[0] += ‘?’;
printf (“Category: “);
gets (InRec [Current].Data_Cat);
if (strcmp (InRec [Current].Data_Cat, “”) == 0)
InRec [Current].Data_Cat[0] += ‘?’;
printf (“Title: “);
gets (InRec [Current].Data_Title);
if (strcmp (InRec [Current].Data_Title, “”) == 0)
InRec [Current].Data_Title[0] += ‘?’;
printf (“Note: “);
gets (InRec [Current].Data_Con);
if (strcmp (InRec [Current].Data_Con, “”) == 0)
InRec [Current].Data_Con[0] += ‘?’;
FILE * Data_Output = fopen (“AllRecords.bin”, “ab”);
fwrite (&InRec, sizeof (AllData), 2, Data_Output);
fclose (Data_Output);
printf (“\n\nSYSTEM: Record Saved!\n”);
system (“pause”);
return (99);
}
int SearchCat ()
{
int RecNum;
FILE * Data_Input = fopen (“AllRecords.bin”, “rb”);
fread (&InRec, sizeof (AllData), 100, Data_Input);
fclose (Data_Input);
char SearchTitle [31], Results [4];
int Track, Select, Found = 0;
system (“cls”);
printf (“\n\nEnter CATEGORY to Search for: “);
gets (SearchTitle);
gets (SearchTitle);
system (“cls”);
printf (“——————————————————-“);
printf (“\n DATE || CATEGORY || TITLE\n”);
printf (“——————————————————-“);
for (Track = 1; Track <= MaxRecNum; Track ++)
{
if (strcmp (InRec [Track].Data_Cat, SearchTitle) == 0)
{
printf ("\n[%2d] %3s || %s || %s\n", Track, InRec [Track].Data_Date, InRec [Track].Data_Cat, InRec [Track].Data_Title);
Found++;
}
}
if (Found == 0)
printf ("\n\nERROR: No Matching Records.\n\n");
else
GetRec (Found, InRec);
system ("pause");
return (99);
}
int SearchTitle ()
{
int RecNum;
FILE * Data_Input = fopen ("AllRecords.bin", "rb");
fread (&InRec, sizeof (AllData), 100, Data_Input);
fclose (Data_Input);
char SearchTitle [31], Results [4];
int Track, Select, Found = 0;
system ("cls");
printf ("\n\nEnter TITLE to Search for: ");
gets (SearchTitle);
gets (SearchTitle);
system ("cls");
printf ("-------------------------------------------------------");
printf ("\n DATE || CATEGORY || TITLE\n");
printf ("-------------------------------------------------------");
for (Track = 1; Track <= MaxRecNum; Track ++)
{
if (strcmp (InRec [Track].Data_Title, SearchTitle) == 0)
{
printf ("\n[%2d] %3s || %s || %s\n", Track, InRec [Track].Data_Date, InRec [Track].Data_Cat, InRec [Track].Data_Title);
Found++;
}
}
if (Found == 0)
printf ("\n\nERROR: No Matching Records.\n\n");
else
GetRec (Found, InRec);
system ("pause");
return (99);
}
int SearchDate ()
{
int RecNum;
FILE * Data_Input = fopen ("AllRecords.bin", "rb");
fread (&InRec, sizeof (AllData), 100, Data_Input);
fclose (Data_Input);
char SearchTitle [31], Results [4];
int Track, Select, Found = 0;
system ("cls");
printf ("\n\nEnter DATE to Search for: ");
gets (SearchTitle);
gets (SearchTitle);
system ("cls");
printf ("-------------------------------------------------------");
printf ("\n DATE || CATEGORY || TITLE\n");
printf ("-------------------------------------------------------");
for (Track = 1; Track <= MaxRecNum; Track ++)
{
if (strcmp (InRec [Track].Data_Date, SearchTitle) == 0)
{
printf ("\n[%2d] %3s || %s || %s\n", Track, InRec [Track].Data_Date, InRec [Track].Data_Cat, InRec [Track].Data_Title);
Found++;
}
}
if (Found == 0)
printf ("\n\nERROR: No Matching Records.\n\n");
else
GetRec (Found, InRec);
system ("pause");
return (99);
}