In: Computer Science
Build a C program project about Personal diary which will have daily note add, remove , edit , search, and view notes system. Write the appropriate comment in your code. Comment writing is mandatory. describe your logic, purpose of a function, purpose of the variable etc need to be described in the comment.
//You have not mentioned what are the attributes of diary product. Hence I am assuming it by myself.
//Name, id, address
struct PersonalDiary
{
char name[50];
int id;
char address[100];
};
void add(struct PersonalDiary diary);
void remove(struct PersonalDiary diary);
void edit(struct PersonalDiary diary);
void search(struct PersonalDiary diary, int myId);
void view(struct PersonalDiary diary);
int main(){
struct PersonalDiary diary;
int res=0;
printf("Please select from following 1. add 2. remove 3. edit 4. seach 5.view ");
int choice;
scanf("%d",&choice);
switch(choice){
case 1: add(diary);
break;
case 2: remove(diary);
break;
case 3: edit(diary);
break;
case 4:
int myid;
scanf("%d",&myid);
search(diary,myid);
break;
case 5: view(diary);
break;
}
return 0;
}
void add(struct PersonalDiary diary){
//You can make this user specific by using scanf()
strcpy(diary.name,"2020 diary");
strcpy(diary.id,12904);
strcpy(diary.address,"German Bakery,Pune");
}
void remove(struct PersonalDiary diary){
diary.name=null;
diary.id=0;
diary.address=null;
}
int search(struct PersonalDiary diary, int id){
if(diary.id==id) return "found";
else return "not found";
}
void edit(struct PersonalDiary diary){
//It must be user manual;
char[50] myname;
scanf("%s",&myname)
strcpr(diary.name,myname);
}
void view(struct PersonalDiary diary){
printf("Name ",&diary.name);
printf("id ",&diary.id);
printf("address ",&diary.address);
}