below is my code.The code is use to update a text file
- copy all required data from "accountInformation.txt" to "temp.txt"
- delete the "accountInformation.txt" file
- rename the "temp.txt" file.
code is working well but only problem i am getting is remove function is not working for "accountInformation.txt". The remove function is working fine for other files.
Also rename function also not working if i am applying it on "accountInformation.txt"
by using errno.h on remove("accountInformation.txt"), its showing error no 13.
void updateRecord(int option)
{
    FILE *fp1;
    int i=1;
    FILE *fp2;
    searchRecord();
    if(option != 5)
    recordInput();
    char buffer[1000];  
    fp2 = fopen("temp.txt", "w");
    fp1 = fopen("accountInformation.txt","r");
    char str[256];
    while(!feof(fp1))
    {
        strcpy(str,"\0");
        fgets(str,256,fp1);
        if(!feof(fp1))
        {
            i++;
            if(i!=record)
            {
                fprintf(fp2,"%s",str);
            }
            else
            {
                if(option == 5)
                {
                     //do nothing
                }
                else
                {   
                    sprintf(buffer, "%d,%s,%s,%s,%s\n",i,accountNumber,firstName,lastName,accountBalance);
            fprintf(fp2,"%s",buffer);
                }
           }
        }
    }
if(fclose(fp1)!=0)
        fprintf(stderr, "Value of errno: %d\n", errno);
fclose(fp2);
   int rem = remove("C:/Users/umer/Desktop/New folder/accountInformation.txt");
   if(rem != 1)
    fprintf(stderr, "Value of errno: %d\n", errno);
rename("temp.txt","accountInformation.txt");
}
 
     
     
    