[SIZE="2"][COLOR="Black"]let me guys, look at my program, i can register upto 3 members and can view it...
but i dont know how to clear the string in 2dimensional array
i declared the variables (ex. name[3][20])
3 for the number of array....
20 for the length of the string...
who can do delete code for the array?
here's my program....
Code:
#include <stdio.h>
#include <string.h>
#define p printf
#define s scanf
int avail=0,slot[3];
char empcode2[20],empcode[3][20],name[3][20];
main()
{
char chmain;
clrscr();
p("[A] - Add\n");
p("[B] - View\n");
p("[C] - Delete\n");
chmain=tolower(getche());
do
{
p("\b");
clreol();
}
while(chmain!='a' && chmain!='b' && chmain!='c');
switch(chmain)
{
case 'a':
add();
exit(0);
break;
case 'b':
view();
exit(0);
break;
case 'c':
delete();
exit(0);
break;
}
getche();
}
add()
{
int x=0;
char chadd;
clrscr();
for(x=0;x<3;x++)
{
if(avail==3)
{
p("MAXIMUM");
getche();
main();
exit(0);
}
if(slot[x]==0)
{
p("Enter Employee Code: ");
s("%s",&empcode[x]);
p("Enter Name: ");
s("%s",&name[x]);
slot[x]=1;
avail++;
}
p("Do You Want To Register Again\n");
p("[Y] - Yes\n");
p("[N] - No\n");
chadd=tolower(getche());
if(chadd=='y')
{
if(avail!=3)
clrscr();
else
{
p("\nMaximum");
getche();
main();
exit(0);
}
}
if(chadd=='n')
{
main();
exit(0);
}
}
}
view()
{
int y=0;
char chview;
clrscr();
p("Enter Employee Code: ");
s("%s",&empcode2);
for(y=0;y<3;y++)
{
if(strcmp(empcode2,empcode[y])==0)
p("%s",name[y]);
}
p("\nDo You Want To Seach Again\n");
p("[A] - Search Again\n");
p("[B] - Main Menu\n");
chview=tolower(getche());
switch(chview)
{
case 'a':
view();
exit(0);
break;
case 'b':
main();
exit(0);
break;
}
getche();
}
delete()
{
int z=0;
char chdelete;
p("Enter Employee Code: ");
s("%s",&empcode2);
for(z=0;z<3;z++)
{
if(strcmp(empcode2,empcode[z])==0)
{
p("%s",name[z]);
chdelete=tolower(getche());
if(chdelete=='y' )
{
/* Space For Delete Code */
}
if(chdelete=='n')
{
main();
exit(0);
}
}
}
]