I have a simple register that requires the user to input a person's first name, last name, age, address and nickname. The assignment is to delete a users record with one option and to delete a single line in another. I'm not sure how to go about the delete.
I have created the general program and I know that it requires an IF statement for the two options but I'm not certain how to go about it.
#include <stdio.h>
int main(){
    int option;
      printf("[1] To create a new student onto the register\n");
      printf("[2] To delete a record in the register\n");
      printf("[3] To delete a line in the register\n");
      printf("Option: ");
      scanf("%d",option);
      if (option==1){
        Register();
      }
      if (option==2){
      }
      if (option==3){
      }
      return 0;
  }
void Register(){
    char Name[100],Address[100],Lname[100],Nickname[100];
    int Age=0,Phoneno=0;
    FILE*fptr;
    fptr = fopen("Register.txt", "a+");
    if(fptr == NULL)
    {
        printf("Error! There is no file to write to. Please Create a file");
    }
    fflush(stdin);
    printf("Enter the first name of a person: ");
    gets(Name);
    printf("Last Name of %s: ",Name);
    gets(Lname);
    printf("What is the age of %s: ",Name);
    scanf("%d", &Age);
    fflush(stdin);
    printf("What is the address of %s: ",Name);
    gets(Address);
    printf("Does %s have a nickname?");
    gets(Nickname);
    printf("This ends the entry of info into the file\n");
    fprintf(fptr,"First name: %s\n",Name);
    fprintf(fptr,"Last name: %s\n"Lname);
    fprintf(fptr,"Age: %d\n",Age);
    fprintf(fptr,"Address: %s\n",Address);
    fprintf(fptr,"Nickname:%s\n\n",Nickname);
    fclose(fptr);
}
- If you choose option 1, the program creates a record of a student.
- If you choose option 2, the program should delete all information about a person if you enter their first name.
- If you choose option 3, the program asks for the students first name then asks which option to delete.
An example for option 3 is
First name: Michael
Last name:
Age:16
Address: 17 Habour street
Nickname: Mike
where his last name was erased
 
    