title: How do I update existing elements in a structure?
body: <p>I am working a program that has to function like an address book. However, I am having trouble trying to have a function that allows the user to update an existing contact's information. I had attempted to modify and use existing functions (as I have one that creates, searches,and deletes a contact) to do this.The code below is how I am trying to approach the problem.</p>
  
  <p>The code:</p>
  
  <pre><code>void updateContact(){
      //Variables
      addressbook tempBook1;
      FILE* fp;
      fp = fopen("contact.txt", "r");
      char add[30], city[20], state[20], zip[10], email[30];
      char name[20];
      char name1[20], phone[20];
      int menuChoice;
  
  
      //Prompt Output
      system("cls");
      outputSearchPrompt()
      scanf("%s", name);
  
      //Search and Update Contact
      while (fscanf(fp, "%s %s %s %s %s %s %s \n", name1, phone, add, city, state, zip, email) != EOF) {
          if (strcmp(name, name1) == 0) {
              displayMenu()
              printf("Enter the number of what you want to update");
              printf("or enter anything else to exit:");
              scanf("%d", &amp;menuChoice);
  
              switch (menuChoice) {
              case 1:
                  printf("Enter the updated name:");
                  //scanf("%s", tempBook1.name);
                  break;
              //More Menu Options for All Elements
              default:
                  printf("Okay");
              }
  
          }
      }
      fclose(fp);
      printf("\n\tPRESS ANY KEY TO CONTINUE");
      _getch();
      main();
  }
  </code></pre>