JamesPowell
Programmer
Hi,
A simple problem, but I just can't get it to work...
I'm trying to read a record from a file, modify it and then write it back to file, updating the original record.
Can anyone tell me what I'm doing wrong.
I'm doing something like this.
void main (int argc, char *argv[])
{
char rec[3];
FILE *fp = fopen("a.dat", "r+");
int bytes = fread(rec, 1, sizeof(rec), fp);
rec[0] = 'V';
bytes = fwrite(rec, 1, sizeof(rec), fp);
fclose(fp);
}
Thanks
James
A simple problem, but I just can't get it to work...
I'm trying to read a record from a file, modify it and then write it back to file, updating the original record.
Can anyone tell me what I'm doing wrong.
I'm doing something like this.
void main (int argc, char *argv[])
{
char rec[3];
FILE *fp = fopen("a.dat", "r+");
int bytes = fread(rec, 1, sizeof(rec), fp);
rec[0] = 'V';
bytes = fwrite(rec, 1, sizeof(rec), fp);
fclose(fp);
}
Thanks
James