void Search()
{
char Find[100],*ptr;
int Found=0, ch;
if((Contactbook=fopen("Contactbook.txt","r"))==NULL)
printf("----The File Is Empty----\n");
else
{
system("clear");
while ((ch = getchar()) != '\n' && ch != EOF);
printf("Enter Name to search:\n");
fgets(Find, sizeof Find, stdin);
if((ptr = strchr(Find, '\n')) != NULL)
*ptr = '\0';
fscanf(Contactbook,"%s %s %s %s %s ",contactbook.names, contactbook.birthday, contactbook.hp, contactbook.address, contactbook.occupation);
if(strcmp(Find,contactbook.names)==0)
Found=1;
if(Found)
{
system("clear");
printf("Name: %s\n",contactbook.names);
printf("Birthday: %s\n",contactbook.birthday);
printf("Handphone: %s\n",contactbook.hp);
printf("Address : %s\n",contactbook.address);
printf("Occupation: %s\n",contactbook.occupation);
}
else if(!Found)
{
printf("SORRY FILE NOT FOUND\n");
}
fclose(Contactbook);
}
}
Grunt 19 Junior Poster
andor 25 Posting Whiz in Training
amano 0 Newbie Poster
andor 25 Posting Whiz in Training
amano 0 Newbie Poster
andor 25 Posting Whiz in Training
amano 0 Newbie Poster
andor 25 Posting Whiz in Training
amano 0 Newbie Poster
andor 25 Posting Whiz in Training
dwks 149 Posting Whiz in Training
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Grunt 19 Junior Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Grunt 19 Junior Poster
Dave Sinkula 2,398 long time no c Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.