Thread: compiler throws error due to the use of "SEEK_SET"

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    182

    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

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Are you actually intending to compile it as C++?

    And I'm sure it's got nothing to do with SEEK_SET...

    Edit: x.C is a C++ file, x.c is a C file. There is nothing in your code indicating that it is ACTUALLY C++, so maybe a "mv fig11_12.C fig11_12.c" will do the trick.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    try this:

    Code:
    mv fig11_12.C fig11_12.c
    cc -Wall -pedantic fig11_12.c
    edit:: Too slow!!

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    182
    You guys are right thanks.

    I thought it had something to do with SEEK_SET because the error showed up when I fixed my typo "SEED_SET"

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by yougene View Post
    You guys are right thanks.

    I thought it had something to do with SEEK_SET because the error showed up when I fixed my typo "SEED_SET"
    Yes, of course, if you have syntactic errors, you will not get linker errors. And the "cxx_personality" is typically a part of the C++ library, which you wouldn't (normally) link with using cc.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler Paths...
    By Cobra in forum C++ Programming
    Replies: 5
    Last Post: 09-26-2006, 04:04 AM
  2. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  3. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM
  4. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM
  5. Bad code or bad compiler?
    By musayume in forum C Programming
    Replies: 3
    Last Post: 10-22-2001, 09:08 PM