HOW CAN I ADD THE FIRST NAME. LAST NAME AND EMAIL ADDRESS TO THE SEARCH LIST? OR CAN YOU USE SWITCH STATEMENT ? THE PROBLEM HERE IS THAT I WANT TO INCLUDE THE FIRST NAME LAST NAMR OR EMAIL ADDRESS TO SEARCH THE PERSON I WANT TO SEARCH void search_person() {     long int phone_1920213;     printf("\n\nEnter Phone number of the person you want to search : ");     scanf("%ld",&phone_1920213);     FILE *fp;     fp = fopen("phonebook_1920213", "rb");     if (fp == NULL)     {        printf("No results! The number you have searched is not of on the list. Plase try again !\n");         //print to continue using the program         //press any key to continue        printf("\nKINDLY PRESS ANY KEY TO CONTINUE USING THE PROGRAM!\n");         return;     }     else     {         int flag = 0;         phonebook_1920213 p;         while (fread(&p, sizeof(p), 1, fp) == 1)         {             if(p.contactnum_1920213 == phone_1920213)             {                 printf("FIRST NAME\t\t\t\t SURNAME\t\t        PHONE NO\t\t         EMAIL\n");  printf("______________________________________________________________________________________________________________________\n");                                  int i;                 int len1 = 40 - strlen(p.fname_1920213);                 int len2 = 20 - strlen(p.lastname_1920213);                 int len3 = 15;                 printf("%s",p.fname_1920213);                 for(i=0;i0;i

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

 

HOW CAN I ADD THE FIRST NAME. LAST NAME AND EMAIL ADDRESS TO THE SEARCH LIST? OR CAN YOU USE SWITCH STATEMENT ? THE PROBLEM HERE IS THAT I WANT TO INCLUDE THE FIRST NAME LAST NAMR OR EMAIL ADDRESS TO SEARCH THE PERSON I WANT TO SEARCH

void search_person()
{
    long int phone_1920213;
    printf("\n\nEnter Phone number of the person you want to search : ");
    scanf("%ld",&phone_1920213);

    FILE *fp;
    fp = fopen("phonebook_1920213", "rb");
    if (fp == NULL)
    {
       printf("No results! The number you have searched is not of on the list. Plase try again !\n");
        //print to continue using the program
        //press any key to continue
       printf("\nKINDLY PRESS ANY KEY TO CONTINUE USING THE PROGRAM!\n");
        return;
    }
    else
    {
        int flag = 0;
        phonebook_1920213 p;
        while (fread(&p, sizeof(p), 1, fp) == 1)
        {
            if(p.contactnum_1920213 == phone_1920213)
            {
                printf("FIRST NAME\t\t\t\t SURNAME\t\t        PHONE NO\t\t         EMAIL\n");
 printf("______________________________________________________________________________________________________________________\n");
                
                int i;
                int len1 = 40 - strlen(p.fname_1920213);
                int len2 = 20 - strlen(p.lastname_1920213);
                int len3 = 15;
                printf("%s",p.fname_1920213);
                for(i=0;i<len1;i++) printf(" ");

                printf("%s",p.lastname_1920213);
                for(i=0;i<len2;i++) printf("  ");

                printf("%ld",p.contactnum_1920213);
                for(i>0;i<len3;i++) printf("   ");

                printf("%s",p.email_1920213);
                printf("\n");

                flag = 1;
                break;
            }
            else continue;
            // fflush(stdin);
        }
        if(flag == 0) 
        {
           
            printf("\nNo Results! The Person you have entered is not in the Phonebook\n");
        }
        fflush(stdin);
        fclose(fp);
        //print to continue using the program
        //press any key to continue
          printf("\nKINDLY PRESS ANY KEY TO CONTINUE USING THE PROGRAM!\n");
    }
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY