Can anyone help me make a pseudocode for this function....cause its really difficult:'(

int updateRecord( FILE *fPtr )
{ 
   int account;        /* account number */
   double transaction; /* transaction amount */

   /* create clientData with no information */
   struct clientData c = { 0, "", "", 0.0 };

   /* obtain number of account to update */
   printf( "Enter Loan No. to update ( 1 - 100 ): " );
   scanf( "%d", &account );

   /* move file pointer to correct record in file */
   fseek( fPtr, ( account - 1 ) * sizeof( struct clientData ), SEEK_SET );

   /* read record from file */
   fread( &c, sizeof( struct clientData ), 1, fPtr );

   /* display error if account does not exist */
   if ( c.acctNum == 0 ) {
      printf( "Loan #%d has no information.\n", account );
   } /* end if */
   else { /* update record */
      printf( "\t\t%-6d   %-16s   %-11s   %10.2f\n\n", 
         c.acctNum, c.lastName, 
         c.firstName, c.balance );
      
      /* request transaction amount from user */ 
      printf( "Enter charge ( + ) or payment ( - ): " );
      scanf( "%lf", &transaction );
      c.balance += transaction; /* update record balance */
      
      printf( "\t\t%-6d   %-16s   %-11s   %10.2f\n", 
         c.acctNum, c.lastName, 
         c.firstName, c.balance );
      
      /* move file pointer to correct record in file */
      fseek( fPtr, ( account - 1 ) * sizeof( struct clientData ), SEEK_SET );

      /* write updated record over old record in file */
      fwrite( &c, sizeof( struct clientData ), 1, fPtr );
   } /* end else */

} /* end function updateRecord */

/* delete an existing record */

Copy/paste all commentaries from the source: it's your desired pseudocode ;)...

Comments
Indeed, if they'd written the pseudo-code first, it would become the comments!

This is not a difficult function nor is it well written.
I would suggest starting with pseudo code (including error handling) and then writing the actual code.

This article has been dead for over six months. Start a new discussion instead.