Hi, I'm writting a text editor in C, and I have a problem.
I isolated the problem to the next simple program:
first, I work with bin files,and when writting to the file or reading,
it's by Str[73].
suppose that we prepared a file with three strings in it,the length of each is 73. now see this program:
void main()
{
FILE *fp;
char Str[73];
fp=fopen("FilePath","r+b");
fread(Str,sizeof(char),73,fp);
fseek(fp,-73L,SEEK_CUR); //return to the beginning of FirstLine
fwrite(Str,sizeof(char),73,fp);
fread(Str,sizeof(char),73,fp); //fail
fread(Str,sizeof(char),73,fp); //fail
fclose(fp);
}
now, I've discovered that putting fseek(fp,ftell(fp),SEEK_SET)
after the fwrite solves the problem.
if anyone knows info that can be help,I will be glade to here.
thx,
gambit
and sorry for my bad english