compiler throws error due to the use of "SEEK_SET"
This is my first time using the fwrite function and SEEK_SET. Does anyone know what's going on? I'm using Ubuntu Linux.
Code:
#include <stdio.h>
struct clientData {
int acctNum;
char lastName[ 15 ];
char firstName[ 10 ];
double balance;
};
int main()
{
FILE *cfPtr;
struct clientData client = { 0, "", "", 0.0 };
if ( ( cfPtr = fopen( "credit.dat", "r+" ) ) == NULL )
printf( "File could not be opened.\n" );
else {
printf( "Enter account number "
" ( 1 to 100, 0 to end input )\n? " );
scanf( "%d", &client.acctNum );
while ( client.acctNum != 0 ) {
printf( "Enter alstname, firstname, balance\n? " );
fscanf( stdin, "%s%s%lf", client.lastName, client.firstName, &client.balance );
//-----------------------------RIGHT HERE----------------------------------
fseek( cfPtr, ( client.acctNum - 1 ) * sizeof( struct clientData ), SEEK_SET );
fwrite( &client, sizeof( struct clientData ), 1, cfPtr );
printf( "Enter account number\n? " );
scanf( "%d", &client.acctNum );
}
fclose( cfPtr );
}
return 0;
}
This is my console output
Code:
eugene@eugene-laptop:~/cfiles$ cc -Wall -pedantic fig11_12.C
/tmp/ccYbgfxw.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status