Originally posted by abhiboy007
i want to edit contents of binary file in which records are stored
record is a structure.
ftp = fopen("stock.dat", "a+" );
1
switch(ch)
2
{
case 2: // option to edit record
{
long int rec = 0, loc = 0;
3
printf("\n Enter record no :- ");
scanf("%ld", &rec);
4
loc = ( rec - 1 ) * sizeof(a) + ( rec - 1 );
5
fseek( fpt, loc, 0 );
6
getdata();
7:
fread( &a, sizeof(a), 1, fpt );
break;
}
}
now problem is that file pointer is positioning properly
but the record is not updated.
please help.