i've got problem in searching plz help me aout.
this is telephone directory program.
coding:
Code:
#include<stdio.h>
#include<conio.h>
void info(void);
void search(void);
struct TD
{
char name[20];
char add[40];
char ph[10];
char email[20];
};
struct TD ppl[50];
int n=0;
void main(void)
{
char ch;
clrscr();
printf ("\t\tTELEPHONE DIRECTORY\n\n");
while (1)
{
printf ("\n\nType 'e' for entering the new information\n");
printf ("Type 's' for search\n");
printf ("Type 'q' for quit");
ch=getche();
switch(ch)
{
case 'e':
info();
break;
case 's':
search();
break;
case 'q':
exit(0);
default:
printf ("Enter only the selection listed");
}
}
}
void info(void)
{
clrscr();
printf ("\nRecord #%d:\nEnter the name:",n+1);
gets (ppl[n].name);
printf ("Enter the address:");
gets (ppl[n].add);
printf ("Enter the telephone #:");
gets (ppl[n].ph);
printf ("Enter the email:");
gets (ppl[n++].email);
}
void search(void)
{
int j,k,position;
char name1[20];
clrscr();
if (n<1)
printf ("Empty list\n");
else
printf ("\n\nEnter the name for information:");
gets(name1);
for ( j=0 ; j<n ; j++)
if ( name1 == ppl[j].name)
{
printf ("\nName: %s",ppl[j].name);
printf ("\nAddress: %s",ppl[j].add);
printf ("\nPhone #: %s",ppl[j].ph);
printf ("\nE-mail: %s",ppl[j].email);
}
else
printf ("\nRecord not found");
}
[code][/code]tagged by Salem