Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#define max 20
typedef struct mk{
char lname[20];
char fname[20];
float qpa;
}dt;
void menu();
display(dt aS[max],int find);
search(dt aS[],int find);
seaNdel(dt aS[],int find);
main()
{
dt aS[max];
char choice;
int find=0,i=0;
float store;
do{
clrscr();
menu();
printf("\nEnter your choice: [ ]\b\b");
choice=toupper(getche());
if(choice!='A' && choice!='B' && choice!='C' && choice!='D' && choice!='E')
{
printf("\nInvalid Choice!!! Choose the ffs: [A/B/C/D/E]");
getch();
}
else if(find<1 && choice!='A' && choice!='E')
{
printf("\nPlease Record a Data first");
getch();
}
else{
switch(choice)
{
case 'A':
fflush(stdin);
find++;
printf("\nPlease Enter Your Last Name: ");
gets(aS[i].lname);
printf("Please Enter your first name: ");
gets(aS[i].fname);
printf("Please Enter your QPA: ");
scanf("%f",&store);
aS[i].qpa=store;
i++;
break;
case 'B':
fflush(stdin);
search(aS,find);
getch();
break;
case 'C':
/*seaNdel(aS,find);*/
getch();
break;
case 'D':
fflush(stdin);
display(aS,find);
getch();
break;
}
}
}while(choice!='E');
printf("\nProgram Terminated\nThank you for using my program");
getch();
}
display(dt aS[],int find)
{
int i,x=20,y=10;
clrscr();
gotoxy(1,y);printf("Last Name:");
gotoxy(1,y+1);printf("First Name:");
gotoxy(1,y+2);printf("QPA:");
for(i=0;i<find;i++){
gotoxy(x,y++);puts(aS[i].lname);
gotoxy(x,y++);puts(aS[i].fname);
gotoxy(x,y++);printf("%.1f",aS[i].qpa);
x+=10; y=10;
}
return;
}
void menu()
{
printf("[A] Add Student Record\n");
printf("[B] Search and Edit a record\n");
printf("[C] Search and delete a record\n");
printf("[D] Display All Records\n");
printf("[E] Exit from the program\n");
return;
}
search(dt aS[],int find)
{
int i,found=0;
float p;
char temp={0},choice;
printf("\nPlease Enter a LastName to search: ");
gets(temp);
for(i=0;i<find;i++)
{
if(strcmpi(aS[i].lname,temp)==0)
{
printf("\nThe name was found...and it is %s",aS[i].lname);
found=1;
break;
}
}
if(found==0){
printf("\nThe name was not found!!!");
}
else {
printf("\nEnter a new QPA to edit: ");
scanf("%f",&p);
aS[i].qpa=p;
}
}
/*seaNdel(dt aS[],int find)*/
thats my code.. and i would appreciate any help in making the search and delete function...
thanks anyway....