I need to add a string before the 45th byte in an existing file. I tried using `fseek` as shown below.

```
int main()
{
    FILE *fp;
    char str[] = "test";     

    fp = fopen(FILEPATH,"a");
    fseek(fp,-45, SEEK_END);                
    fprintf(fp,"%s",str);
    fclose(fp);     
    return(0);
}

```

I expected that this code will add "test" before the 45th char from EOF, instead, it just appends "test" to the EOF.

Please help me to find the solution. 

This is continuation of my previous question  

[Append item to a file before last line in c](https://stackoverflow.com/questions/3262886/append-item-to-a-file-before-last-line-in-c)