How do I got about renaming a file the file is called "Patient.txt" and i wish for it to be called whatever value is stored in the string "surname" after the string combine. I know my code is also riddled with small errors and bad practises which I will try and amend however im looking to fix the FILE name problem.
FILE*fopenFile(char fileName[], char fileMode[])
{
     int height, weight;
     char name[25], issues[30], curMeds[30], surname[25], birthDay[6];
     FILE *fbor = fopen(fileName, fileMode); 
     if(!fbor)
     {
        puts("Unable to open File");
        exit(1);
     }
     printf("Enter First name: ");
     scanf("%s", name);  
     printf("Enter Surname: ");
     scanf("%s", surname);  
     printf("Enter your DoB (ddmmyy): ");
     scanf("%s", birthDay);
     printf("Enter weight (Kg): ");
     scanf("%d", &weight);
     printf("Enter Height in CM: ");
     scanf("%d", &height);
     printf("Enter Medical Issues: ");
     fgets(issues, 30, stdin);
     emptyBuffer();
     printf("Enter Current Medication: ");
     fgets(curMeds, 30, stdin);
     
     fprintf(fbor, "First Name: %s\n", &name[25]);
     fprintf(fbor, "Surname: %s\n", &surname[25]);
     fprintf(fbor, "DoB: %s\nHeight: %d\n", &birthDay[6], height);
     fprintf(fbor, "Weight: %d\n", weight);
     fprintf(fbor, "Medical issues: ");
     fprintf(fbor, issues);
     fprintf(fbor, "Current medication: ");
     fprintf(fbor, curMeds);
     fclose(fbor);
     
     char fileType[] = ".mxa";
     
     strncat(surname, birthDay, 6);
     strncat(surname, fileType, 4);
     
     printf("\n  ..............................");
     printf("\n   File Saved as %s", surname);
     printf("\n  ..............................\n\n\n");
     
     if (rename(fileName, surname) == 0)
     {
        printf("File renamed successfully.\n");
     }
     else
     {
        printf("rename file failed.\n");
     }
     exit(0);
     
     return 0;
}
The files Name is not changing.
 
     
    