I've gotten myself a bit confused here. :'(

I've created two linked lists called 'competitors' and 'races'. I'm able to add, append and display info in both files but unable to delete or update the information contained in either. I've started the coding for both functions but have got totally lost.

I need to submit this on Monday so I'm pretty much out of time with regard to tweaking my code so if anyone could sort this out for me I'd be extremely grateful...

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
char f_menu ();
/* Prototypes */
void f_create_driver ( char * );
void f_display_driver ();
void f_copy_race_file();
int f_display_this_driver ( int );
void f_create_race ( char * );
void f_display_race ();
void f_driver_menu();
void f_race_menu();
void f_delete_driver ();
void f_update_race ();
void f_delete_race ();
void f_update_driver();
 
/* Driver record */
typedef struct
{
    int identity;
    char name[30];
    char clas[10];
    char entry[20];
} DRIVERTYPE;
DRIVERTYPE driver;

/*Race Results record */
typedef struct
{
    int identity;
    char title[20];
    int driver_identity;
    int points;
    float speed;
    int laps;
    float gap;
    float best;
    char date[30];
    char conditions[20];
    float length;
    int start;
    int end;
} RACETYPE;
RACETYPE race;
DRIVERTYPE f_update_driver_record( DRIVERTYPE driver );

/* Main function */
main ()
{
    char choice;
    do
 {
 /* Call main menu - drivers or race results */
    choice = f_menu ();
     switch ( choice )
  {
  /* Process driver file */
      case '1' : f_driver_menu  ();
          break;
   /* Process race results file */
      case '2' : f_race_menu  ();
          break;
  /* Quit system */
      case 'Q' :
      case 'q' : printf ( "Quit\n\n" );
          break;
  }
 }
 while (( choice != 'Q' ) && ( choice != 'q' ));
 exit (0);
}

/* ************************************************************************** */
/* Main menu function */
char f_menu ()
{
 char select;
 do
 {
 printf ( "\n\n\n\n\n\n");
        printf ( "********************************************************\n" ); 
        printf ( "********************************************************\n" );
 printf ( "********************************************************\n" );
        printf ( "*********** The British Superkart Racing Club **********\n" );
        printf ( "****************** Data Logging System *****************\n" );
        printf ( "********************************************************\n" );
 printf ( "********************************************************\n" );
        printf ( "********************************************************\n" );
 printf ( " \n\n\n\n" );
     
        printf ( "+----------------------------------------+\n" );
        printf ( "|                                        |\n" );
        printf ( "|   MAIN MENU                            |\n" );
        printf ( "|                                        |\n" );
 printf ( "|   1 - Driver file                      |\n" );
        printf ( "|                                        |\n" );
        printf ( "|   2 - Race Results file                |\n" );
        printf ( "|                                        |\n" );
        printf ( "|   Q - Quit                             |\n" );
        printf ( "|                                        |\n" );
        printf ( "+----------------------------------------+\n\n" );
 printf ( "Enter a character that corresponds to your choice >  " );
 scanf  ( "%c", &select );
 fflush (0);
 printf ( "\n\n\n\n\n\n" );
 if (( select != 'Q' ) && ( select != 'q' ) && ( select != '1' ) && ( select != '2' ))
  {
      printf ( "You have entered an invalid choice. Please try again\n\n\n" );
  }
 }
 while (( select != 'Q' ) && ( select != 'q' ) && ( select != '1' ) && ( select != '2' ));
 return select;
}
/* ************************************************************************** */
/* Driver Menu function */
void f_driver_menu ()
{
 char choice;
 do
 {
  /* Make choice between driver file processes */
     {
   
               printf ( "+---------------------------------------+\n" );
               printf ( "|                                       |\n" );
               printf ( "|   DRIVER FILE MENU                    |\n" );
        printf ( "|                                       |\n" );
        printf ( "|   C - Create the driver file          |\n" );
               printf ( "|                                       |\n" );
               printf ( "|   A - Append driver record            |\n" );
               printf ( "|                                       |\n" );
               printf ( "|   D - Display the driver record       |\n" ); 
               printf ( "|                                       |\n" );
               printf ( "|   E - Delete driver file              |\n" );
               printf ( "|                                       |\n" );
               printf ( "|   U - Update driver file              |\n" );
               printf ( "|                                       |\n" );
               printf ( "|   Q - Return to main menu             |\n" );
               printf ( "|                                       |\n" ); 
               printf ( "+---------------------------------------+\n\n" );
        printf ( "Enter a character that corresponds to your choice >  " );
        scanf  ( "%c", &choice );
        fflush (0);
        printf ( "\n" );
   if (( choice != 'Q' ) && ( choice != 'q' ) && ( choice != 'C' ) && ( choice != 'c' ) && ( choice != 'A' ) && ( choice != 'a' ) && ( choice != 'D' ) && ( choice != 'd' ) && ( choice != 'U' ) && ( choice != 'u' ) && ( choice != 'E' ) && ( choice != 'e' ))
  {
      printf ( "You have entered an invalid choice.  Please try again\n\n\n" );
  }
 }
  while (( choice != 'Q' ) && ( choice != 'q' ) && ( choice != 'C' ) && ( choice != 'c' ) && ( choice != 'A' ) && ( choice != 'a' ) && ( choice != 'D' ) && ( choice != 'd' ) && ( choice != 'U' ) && ( choice != 'u' ) && ( choice != 'E' ) && ( choice != 'e' ));
  /* Do driver file processes */
  switch ( choice )
  {
   case 'C' :
   case 'c' : f_create_driver ( "wb" );
       break;
   case 'A' :
   case 'a' : f_create_driver ( "ab" );
       break;
         
    case 'D' :
   case 'd' : f_display_driver ();
       break; 
   case 'E' :
   case 'e' : f_delete_driver ();
       break;
    case 'U' :
   case 'u' : f_update_driver ();
       break;  
   case 'Q' :
   case 'q' : printf ( "\n\nReturning to Main Menu\n\n" );
       break;
  }
 }
 while (( choice != 'Q' ) && ( choice != 'q' ));
}

/* ************************************************************************** */
/* Race Results Menu function */
void f_race_menu ()
{
    char choice;
    do
    {
 /* Make choice between race results file processes */
 do
     {
                printf ( "+---------------------------------------+\n" );
                printf ( "|                                       |\n" );
                printf ( "|   RACE RESULTS MENU                   |\n" );
                printf ( "|                                       |\n" ); 
  printf ( "|   C - Create the race results file    |\n" );
                printf ( "|                                       |\n" );   
                printf ( "|   A - Append the race results file    |\n" );
                printf ( "|                                       |\n" );
                printf ( "|   D - Display the race results file   |\n" );
                printf ( "|                                       |\n" );
                printf ( "|   E - Delete race file                |\n" );
                printf ( "|                                       |\n" );
                printf ( "|   U - Update race results file        |\n" );  
                printf ( "|                                       |\n" );
                printf ( "|   Q - Return to main menu             |\n" );
                printf ( "|                                       |\n" );
                printf ( "+---------------------------------------+\n\n\n" );
  printf ( "Enter a character that corresponds to your choice >  " );
  scanf  ( "%c", &choice );
  fflush (0);
  printf ( "\n" );
  if (( choice != 'Q' ) && ( choice != 'q' ) && ( choice != 'C' ) && ( choice != 'c' ) && ( choice != 'A' ) && ( choice != 'a' ) && ( choice != 'D' ) && ( choice != 'd' ) && ( choice != 'U' ) && ( choice != 'u' ) && ( choice != 'E' ) && ( choice != 'e' ))
            {
           printf ( "You have entered an invalid choice. Please try again\n\n\n" );
     }
    }
  while (( choice != 'Q' ) && ( choice != 'q' ) && ( choice != 'C' ) && ( choice != 'c' ) && ( choice != 'A' ) && ( choice != 'a' ) && ( choice != 'D' ) && ( choice != 'd' ) && ( choice != 'U' ) && ( choice != 'u' ) && ( choice != 'E' ) && ( choice != 'e' ));
  /* Do race file processes */
  switch ( choice )
  {
      case 'C' :
      case 'c' : f_create_race ( "wb" );
          break;
      case 'A' :
      case 'a' : f_create_race ( "ab" );
          break;
      case 'D' :
      case 'd' : f_display_race ();
          break;
      case 'E' :
      case 'e' : f_delete_race ();
          break;
      case 'U' :
      case 'u' : f_update_race ();
          break;
      case 'Q' :
      case 'q' : printf ( "Return to main menu\n\n" );
          break;
  }
 }
 while (( choice != 'Q' ) && ( choice != 'q' ));
}

/* ************************************************************************** */
/* Create the drivers file */
void f_create_driver  ( char *file_type )
{
 FILE *fp;
 char reply;

 if ((fp = fopen ( "competitors", file_type )) == NULL )
 {
     printf ( "Cannot open file\n" );
     return;
 }
 do
 {
     /* Enter fields into driver record */
     printf ( "\n\nEnter driver ID  > " );
     scanf  ( "%d", &driver.identity );
     fflush (0);
     printf ( "\n\nEnter driver name > " );
     gets   ( driver.name );
     fflush (0);
     printf ( "\n\nEnter racing class  > " );
     gets   ( driver.clas );
     fflush (0);
     printf ( "\n\nEnter engine/chassis  > " );
     gets   ( driver.entry );
     fflush (0);
       
 /* Write driver record to file */
      fwrite ( &driver, sizeof( DRIVERTYPE ), 1, fp );
  do
  {
      printf ( "\n\nAdd another driver? > " );
      scanf  ( "%c", &reply );
      fflush (0);
  }
  while (( reply != 'Y' ) && ( reply != 'y' ) && ( reply != 'N' ) && ( reply != 'n' ));
 }
 while (( reply  == 'Y' ) || ( reply  == 'y' ));
 fclose (fp);
}

/* ************************************************************************** */
/* Display the whole driver file */
void f_display_driver  ()
{
 FILE *fp;
 if ((fp = fopen ( "competitors", "rb" )) == NULL )
 {
     printf ( "Cannot open file\n" );
     return;
 }
 /* Read first driver record */
 fread ( &driver, sizeof( DRIVERTYPE ), 1, fp );
 /* Keep going up to end of file marker */
 while (!(feof (fp)))
 {
            printf ( "\n\n\n");
            printf ( "Driver ID:       %d\n", driver.identity );
         printf ( "Driver Name:     %s\n", driver.name );
         printf ( "Racing Class:    %s\n", driver.clas );
         printf ( "Engine/chassis:  %s\n\n\n\n", driver.entry );
/*         printf ( "Race Time:       %1.2f seconds\n", driver.speed );
         printf ( "Laps Completed:  %d\n", driver.laps );
         printf ( "Gap:             %1.2f seconds behind leader\n", driver.gap );
         printf ( "Best Lap:        %1.2f seconds\n", driver.best );
*/         
           
       
  /* Read subsequent driver records */
  fread ( &driver, sizeof( DRIVERTYPE ), 1, fp );
 }
}

/* ************************************************************************** */
/* Display one particular driver record */
/* This function finds and displays race results for the driver */
/* Get identity of matching record through parameter passed from race results file*/
int f_display_this_driver  ( int driver_ident)
{
 FILE *fp;
 int found;
 if ((fp = fopen ( "competitors", "rb" )) == NULL )
 {
     printf ( "Cannot open file\n" );
     return;
 }
 /* Matching record not yet found */
 found = 0;
 /* Read first driver record */
 fread ( &driver, sizeof( DRIVERTYPE ), 1, fp );
 /* Search while not yet end of file and matching record not yet found */
 while (!(feof (fp)) && (found == 0))
 {
     /* Check if this is matching record */
     if ( driver.identity == driver_ident )
         {
      /* Set flag to show matching record has been found */
      found = 1;
      /* Display details of matching record */
      printf ( "%d  %s   %s    %s", driver.identity, driver.name, driver.clas, driver.entry );

  }
  /* Read subsequent records */
  fread ( &driver, sizeof( DRIVERTYPE ), 1, fp );
 }
  /* If at end of file without finding matching record, record not there */
 if ( found == 0 )
 {
     printf ( "No matching record found.\n\n\n" );
 }
}

/* ************************************************************************** */
/* Create the race results file */
void f_create_race  ( char *file_type )
{
 FILE *fp;
 char reply;
 if ((fp = fopen ( "races", file_type )) == NULL )
 {
     printf ( "Cannot open file\n" );
     return;
 }
 do
 {
     /* Type fields in race results record */
            printf ( "\n\nEnter race date eg. Sunday, 5 November 2006 > " );
            gets   ( race.date );
            fflush (0);
     printf ( "\n\nEnter race results no. > " );
     scanf  ( "%d", &race.identity );
     fflush (0);
     printf ( "\n\nEnter circuit name  > " );
     gets   ( race.title );
     printf ( "\n\nEnter driver identity number for this race > " );
     scanf  ( "%d", &race.driver_identity );
     fflush (0);
                 
            printf ( "\n\nEnter driver time  > " );
            scanf  ( "%f", &race.speed );
            fflush (0);
            
            printf ( "\n\nEnter laps completed  > " );
            scanf  ( "%d", &race.laps );
            fflush (0);
            
            printf ( "\n\nEnter gap (behind leader)  > " );
            scanf  ( "%f", &race.gap );
            fflush (0);
            printf ( "\n\nEnter best lap time  > " );
            scanf  ( "%f", &race.best );
            fflush (0);
            printf ( "\n\nEnter points awarded > " );
            scanf  ( "%d", &race.points );
            fflush (0);
     printf ( "\n\nEnter circuit length > " );
     scanf  ( "%f", &race.length );
     fflush (0);
            printf ( "\n\nEnter weather/track eg. Sunny/Dry > " );
            gets   ( race.conditions );
            fflush (0);
     printf ( "\n\nEnter race start time eg. 1247 > " );
     scanf  ( "%d", &race.start );
     fflush (0);
     printf ( "\n\nEnter race finish time eg. 1257 > " );
     scanf  ( "%d", &race.end );
     fflush (0);

     /* Write record to race results file */
     fwrite ( &race, sizeof(RACETYPE ), 1, fp );
  do
  {
      printf ( "\n\nAdd another race result? > " );
      scanf  ( "%c", &reply );
      fflush (0);
  }
  while (( reply != 'Y' ) && ( reply != 'y' ) && ( reply != 'N' ) && ( reply != 'n' ));
 }
 while (( reply == 'Y' ) || ( reply == 'y' ));
 fclose (fp);
}

/* ************************************************************************** */
/* Display the race results file */
void f_display_race  ()
{
 FILE *fp;
 if ((fp = fopen ( "races", "rb" )) == NULL )
 {
     printf ( "Cannot open file\n" );
     return;
 }
 /* Read first race results record */
 fread ( &race, sizeof( RACETYPE ), 1, fp );
 /* Keep going up to end of file marker */
 while (!(feof (fp)))
 {
     /* Display circuit name and race result details*/
     printf ( "\n\n\n\n\n\t\tTHE BRITISH SUPERKART RACING CLUB\n\n" );
            printf ( "\t\t\t%s\n\n", race.date );

            printf ( "Race Result - Race %d                             %s\n\n\n\n", race.identity, race.title );

        printf ( "ID  NAME         CLASS      ENTRY        \n" );
 printf ( "---------------------------------------\n\n" );             
                  f_display_this_driver ( race.driver_identity );                
                  /* fread ( &race, sizeof ( RACETYPE ), 1, fp ); */
        printf ( "\n\n=======================================\n\n\n" );
        printf ( "Time:    %1.2f\n\n", race.speed );
        printf ( "Laps:    %d\n\n", race.laps );               
        printf ( "Gap:     %1.2f\n\n", race.gap );
        printf ( "Best:    %1.2f\n\n", race.best );
        printf ( "Points:  %d\n\n\n", race.points );  
 printf ( "=======================================" );
 
        printf ( "\n\n\n\n" );
        printf ( "Circuit Length: %1.2f miles\n\n", race.length );
        printf ( "Weather/Track: %s                      Start: %d   End: %d\n\n\n\n\n\n", race.conditions, race.start, race.end );

  /* Read subsequent race results records */
  fread ( &race, sizeof( RACETYPE ), 1, fp );
 }
 
}
/* ************************************************************************** */
void f_delete_driver ()
{
    char reply;
    int number;
    DRIVERTYPE driver;
    DRIVERTYPE remove = { 0, "", "", "" };
    FILE *fp;

    if (( fp = fopen ( "competitors", "r+" )) == NULL )
    {
        printf ( "Cannot open file\n\n" );
 return;
    }
    do
           {
          printf ( "\n\nEnter Driver ID to be deleted  >  " );
            scanf  ( "%d", &number );
            fflush (0);
           fseek ( fp, ( number - 1 ) * sizeof( DRIVERTYPE ), SEEK_SET );
            fread ( &driver, sizeof( DRIVERTYPE ), 1, fp );
               if (( number < 0 ) || ( number > 200 ))
               {
                  printf ( "Driver %d does not exist. Please try again.\n\n\n\n", number );
               }
       else
           if ( number != driver.identity )
        {
                  printf ( "No records for driver %d found.\n", number );
           }
 else
    {
  fseek ( fp, ( number - 1 ) * sizeof( DRIVERTYPE ), SEEK_SET );
  fwrite( &remove, sizeof( DRIVERTYPE ), 1, fp );
     }
        do
        {
            printf ( "ID\tNAME\t\tCLASS\tENTRY\n" );
            printf ( "----------------------------------------------------------------------\n" );
            printf ( "%d\t%s\t\t%s\t%s\n\n", driver.identity, driver.name, driver.clas, driver.entry );
            printf ( "----------------------------------------------------------------------\n\n" );
            printf ( "\n\nRecord deleted\n" );
     printf ( "\n\nWould you like to delete another record?\n" );
     printf ( "\n\nPlease enter Y or N only > " );
     scanf  ( "%c", &reply );
     fflush (0);
        }
 while (( reply != 'Y' ) && ( reply != 'y' ) && ( reply != 'N' ) && ( reply != 'n' ));
 }
 while (( reply == 'Y' ) || ( reply == 'y' ));
 fclose (fp);
}
/* ************************************************************************** */
/* Update the records for each driver  */
void f_update_driver ( )
{
    DRIVERTYPE driver;
    char reply;
    int number;
    int found = 0;
    FILE *fp;
    FILE *fp_temp;
    if (( fp = fopen ( "competitors", "r+" )) == NULL )
    {
        printf ( "Cannot open file\n" );
        return;
    }
    if (( fp_temp = fopen ( "tempfile", "w" )) == NULL )
    {
        printf ( "Cannot open file\n" );
        return;
    }

    printf ( "\n\nEnter driver id (1 - 200) to be updated  > " );
    scanf ( "%d", &number );
    fflush(0);
     
    fread ( &driver, sizeof( DRIVERTYPE ), 1, fp );
    while( !(feof( fp ) ) )  
    {
        if ( number == driver.identity )
        {
             found = 1;
               
              /* do what needs to,be done here  */
            driver = f_update_driver_record( driver );
        }
        fwrite( &driver, sizeof( DRIVERTYPE ), 1, fp_temp );
    }
    if( found == 0 )
    {
          printf ( "No records for driver %d has been found\n", number );
    }
    unlink ( "competitors" );
    rename ( "temp", "competitors" );
}
 
 
DRIVERTYPE f_update_driver_record ( DRIVERTYPE driver )
{
char new_driver[30];
char new_clas[5];
char new_entry[20];
   {
      printf ( "DRIVER ID: %d\nDRIVER NAME: %s\nCLASS: %s\nENTRY: %s\n\n\n", driver.identity, driver.name, driver.clas, driver.entry );
      printf ( "\n\nEnter new driver name > " );
      gets  ( new_driver );
          
      strcpy ( driver.name, new_driver );
      
      printf ( "\n\nDRIVER ID: %d\nDRIVER NAME: %s\nCLASS: %s\nENTRY: %s\n\n\n", driver.identity, driver.name, driver.clas, driver.entry );
      printf ( "\n\nEnter class > " );
      gets   ( new_clas );
      strcpy ( driver.clas, new_clas );
      printf ( "\n\nDRIVER ID: %d\nDRIVER NAME: %s\nCLASS: %s\nENTRY: %s\n\n\n", driver.identity, driver.name, driver.clas, driver.entry );
      printf ( "\n\nEnter entry > " );
      gets  ( new_entry );
      fflush (0);
       
      strcpy ( driver.entry, new_entry );
      printf ( "\n\nDRIVER ID: %d\nDRIVER NAME: %s\nCLASS: %s\nENTRY: %s\n\n\n", driver.identity, driver.name, driver.clas, driver.entry );
      return driver;
     
   }
}

/* ************************************************************************** */

void f_delete_race ()
{
    char reply;
    int number;
    RACETYPE race;
    RACETYPE remove = { 0, "", 0, 0, 0, 0, 0, 0, "", "", 0, 0, 0 };
    FILE *fp;

    if (( fp = fopen ( "races", "r+" )) == NULL )
    {
        printf ( "Cannot open file\n\n" );
 return;
    }
 do
        {
       printf ( "\n\nEnter Driver ID to be deleted ( 1 - 200 ) >  " );
         scanf  ( "%d", &number );
         fflush (0);
        fseek ( fp, ( number - 1 ) * sizeof( RACETYPE ), SEEK_SET );
         fread ( &race, sizeof( RACETYPE ), 1, fp );

            if (( number < 0 ) || ( number > 200 ))
            {
                printf ( "Race No. %d does not exist. Please try again.\n\n\n\n", number );
            }
     else
             if ( number != race.identity )
      {
                    printf ( "No records for Race No. %d found.\n", number );
             }
          else
    {
       fseek ( fp, ( number - 1 ) * sizeof( RACETYPE ), SEEK_SET );
       fwrite( &remove, sizeof( RACETYPE ), 1, fp );
     }
        do
        {
         printf ( "\n\nWould you like to delete another record?\n" );
       printf ( "\n\nPlease enter Y or N only > " );
       scanf  ( "%c", &reply );
       fflush (0);
        }
 while (( reply != 'Y' ) && ( reply != 'y' ) && ( reply != 'N' ) && ( reply != 'n' ));
 }
 while (( reply == 'Y' ) || ( reply == 'y' ));
 fclose (fp);
}
/* ************************************************************************** */
/* Update the records for each race  */
void f_update_race ()
{
    RACETYPE race;
    char reply;
    int number;
    char new_title[30];
    int new_driver_identity;
    int new_points;
    float new_speed;
    int new_laps;
    float new_gap;
    float new_best;
    char new_date[30];
    char new_conditions[20];
    float new_length;
    int new_start;
    int new_end;
    FILE *fp;
    if (( fp = fopen ( "races", "r+" )) == NULL )
    {
        printf ( "Cannot open file\n" );
        return;
    }
 printf ( "\n\nEnter Race Number (1 - 200) to be updated  > " );
 scanf  ( "%d", &number );
 fflush (0);
     
        fseek ( fp, ( number - 1 ) * sizeof( RACETYPE ), SEEK_SET );
        fread ( &race, sizeof( RACETYPE ), 1, fp );
     if ( number != race.identity )
            {
         printf ( "Race No. %d does not exist. Please try again.\n", number );
    return;
            }
         else
             if (( number < 0 ) || ( number > 200 ))
             {
          printf ( "No records for Race No. %d has been found\n", number );
          return;
                    }
   do
                 {
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter circuit name:  " );
       gets   ( new_title );
          
       strcpy ( race.title, new_title );

                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );
                     
       printf ( "\n\nEnter driver's identity no:  " );
       scanf  ( "%d", &new_driver_identity );
              fflush (0);
              
                     race.driver_identity = new_driver_identity;
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter points awarded:  " );
       scanf  ( "%d", &new_points );
              fflush (0);
          
       race.points = new_points;
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter length of time to finish race:  " );
       scanf  ( "%f", &new_speed );
              fflush (0);
          
       race.speed = new_speed;
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter laps completed:  " );
       scanf  ( "%d", &new_laps );
              fflush (0);
          
       race.laps = new_laps;
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter time gap behind leader:  " );
       scanf  ( "%f", &new_gap );
              fflush (0);
          
       race.gap = new_gap;
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter best lap time:  " );
       scanf  ( "%f", &new_best );
              fflush (0);
          
       race.best = new_best;
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter date:  " );
       gets  ( new_date );
          
       strcpy ( race.date, new_date );
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter weather/track condition:  " );
       gets ( new_conditions );
 
       strcpy ( race.conditions, new_conditions );
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter length of circuit:  " );
       scanf  ( "%f", &new_length );
              fflush (0);
          
       race.length = new_length;
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter time race commenced:  " );
       scanf  ( "%d", &new_start );
              fflush (0);
          
       race.start = new_start;
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       printf ( "\n\nEnter time race finished:  " );
       scanf  ( "%d", &new_end );
              fflush (0);
          
       race.end = new_end;
                     printf ( "%d~%s~%d~%d~%1.2f~%d~%1.2f~%1.2f~%s~%s~%1.2f~%d~%d\n\n", race.identity, race.title, race.driver_identity, race.points, race.speed, race.laps, race.gap, race.best, race.date, race.conditions, race.length, race.start, race.end );

       fseek  ( fp, ( number - 1 ) * sizeof( RACETYPE ), SEEK_SET );
       fwrite ( &race, sizeof( RACETYPE ), 1, fp );
       do
                        {
                            printf ( "\n\nWould you like to update another record? \n" );
           printf ( "\nPlease enter Y or N only > " );
           scanf  ( "%c", &reply );
           fflush (0);
            }
       while (( reply != 'Y' ) && ( reply != 'y' ) && ( reply != 'N' ) && ( reply != 'n' ));
      }
       while (( reply == 'Y' ) || ( reply == 'y' ));
 fclose (fp);
}
 
/* ************************************************************************** */

Thanks for your help!!

Recommended Answers

All 9 Replies

post only the relevant parts of your code. Noone's going to look through hundreds to thousands of lines of code to find the few where the core problems are.

>>fflush (0);
That is non-standard, should be fflush (stdout); . Any attempt to use fflush() on an input stream like stdin will result in undefined/unpredictable behavior.

>>>fflush (0);
>That is non-standard
No, it's well defined by the standard. If the argument is a null pointer, all open output streams are flushed.

I have a some questions, how is your input filters supposed to work, I see some lines like this:

while (( select != 'Q' ) && ( select != 'q' ) && ( select != '1' ) && ( select != '2' ));

If the user enters the wrong input, the programs goes into a infinite loop...?

Thank you for your response, however this problem has now been resolved.

forum etiquette both here and elsewhere says you share your insights when you find a solution.

>>>fflush (0);
>That is non-standard
No, it's well defined by the standard. If the argument is a null pointer, all open output streams are flushed.

true, fflush(stdout) is well defined, 0 is stdin not stdout

>true, fflush(stdout) is well defined
:icon_rolleyes: You have no idea what I'm talking about, do you? fflush takes a FILE* as its argument. If that pointer is a null pointer, fflush is required by the C standard to write all unwritten data from every open output stream. stdout is included in that, as is stderr and any other output stream that was opened by the program.

>0 is stdin not stdout
No. You're confused about the difference between a file descriptor and a FILE pointer. stdin isn't (and can't be) 0 because that would make it a null pointer when treated as a standard FILE*. stdin is likely to be defined like this:

#define stdin (&__iob[0])
#define stdout (&__iob[1])
#define stderr (&__iob[2])

Where __iob is an array of FILE, and FILE is a structure that contains various useful information (such as buffering and positioning) that may or may not include a file descriptor depending on how I/O works on the system.

Yes, as always, you are right. I stand corrected. The link I posted shows the POSIX file descriptors, which are different then FILE handles.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.