קוד:
void deleteRecord(FILE *fd)
{
int opId, acctNum;
struct account temp = { 0, "", 0, 0.0 };
struct account empty = { 0, "", 0, 0.0 };
printf( "Enter Account number and operation Id\n?>" );
scanf( "%d%d",&acctNum,&opId);
rewind( fd );
while ( !feof( fd ) )
{
fread( &temp, sizeof( struct account ), 1, fd );
if(temp.acctNum==acctNum && temp.opId==opId)
{ //record found
fseek(fd,ftell(fd)-sizeof(struct account),SEEK_SET); //move to the start of the last record;
fwrite( &empty,sizeof( struct account ), 1, fd ); //write an empty record
}
temp.acctNum=0;
} //end while
} //end function