M
Matrixinline
Hi All,
Can I read or write data after I encounter EOF in a file. I tried the
below code to write to a file it did not throw any error.
FILE *fFile = fopen(sFilePath, "a+");
if(fFile != NULL)
{
int iSize = fseek(fFile, 0, SEEK_END);
fwrite(sData,1, strlen(sData), fFile);
fwrite(",",1, strlen(","), fFile);
fwrite(sdata2, 1, strlen(sData2), fFile);
fwrite("\0",1, 1, fFile);
fclose(fFile);
}.
and for reading I used like this
FILE *fFile = fopen(sFilePath, "r");
if(fFile != NULL)
{
int iSize = fseek(fFile, 0, SEEK_END);
while (!feof(fFile))
{
char sData[128];
fread(sData, 1, 10, fFile);
printf("%s", sData);
}
fclose(fFile);
}
but it did not read the data I have written to the file.
Can you please let me know what I am doing wrong ?
Thanks
Anup
Can I read or write data after I encounter EOF in a file. I tried the
below code to write to a file it did not throw any error.
FILE *fFile = fopen(sFilePath, "a+");
if(fFile != NULL)
{
int iSize = fseek(fFile, 0, SEEK_END);
fwrite(sData,1, strlen(sData), fFile);
fwrite(",",1, strlen(","), fFile);
fwrite(sdata2, 1, strlen(sData2), fFile);
fwrite("\0",1, 1, fFile);
fclose(fFile);
}.
and for reading I used like this
FILE *fFile = fopen(sFilePath, "r");
if(fFile != NULL)
{
int iSize = fseek(fFile, 0, SEEK_END);
while (!feof(fFile))
{
char sData[128];
fread(sData, 1, 10, fFile);
printf("%s", sData);
}
fclose(fFile);
}
but it did not read the data I have written to the file.
Can you please let me know what I am doing wrong ?
Thanks
Anup