S
shalakasan
Hi,
I want to open a binary file and write to a specific location in File.
Here is how my code looks like:
int main()
{
long lbuf = 0;
int lreadBytes = 0;
long lValue = 0;
FILE *pFile = fopen ("c:\\TestBin.bin","ab+");
fseek(pFile,4,SEEK_SET);
lValue = 222.4;
fwrite((char *)&lValue,1,sizeof(long),pFile);
fclose(pFile);
return 0;
}
This code writes to the end of file because I have opened it in append
mode. If I open in "wb+" mode the file gets erased. How do i write to
existing file?
Thanks and Regards,
Shal
I want to open a binary file and write to a specific location in File.
Here is how my code looks like:
int main()
{
long lbuf = 0;
int lreadBytes = 0;
long lValue = 0;
FILE *pFile = fopen ("c:\\TestBin.bin","ab+");
fseek(pFile,4,SEEK_SET);
lValue = 222.4;
fwrite((char *)&lValue,1,sizeof(long),pFile);
fclose(pFile);
return 0;
}
This code writes to the end of file because I have opened it in append
mode. If I open in "wb+" mode the file gets erased. How do i write to
existing file?
Thanks and Regards,
Shal