Thread: Runtime Error R6002 - floating point support not loaded

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    132

    Runtime Error R6002 - floating point support not loaded

    Hello, everyone. I wrote a program that use a struct to represent an athlete. The program allocates memory for an array of 5 Athletes, and, soon after I enter the fourth data (height) for the first athlete, I get the message "runtime Error R6002 - floating point support not loaded". The program doesn't reach the line where __LINE__ would be printed. What am I doing wrong? Thanks in advance.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    typedef struct athlete {
        char name[ 100 ];
        char sport[ 100 ];
        double height;
        int age;
    } Athlete;
    
    void sort_array_of_athletes_in_place( Athlete **array );
    
    int main( void )
    {
        Athlete *athleteArray = malloc( 5 * sizeof( Athlete ) );
        unsigned int i = 0;
        unsigned int j;
        
        while ( i < 5 )
        {
            printf( "Enter the name of athlete %d: ", ( i + 1 ) );
            fgets( athleteArray[ i ].name, 100, stdin );
            fflush( stdin );
            
            j = 0;
            
            while ( *( athleteArray[ i ].name + j ) != '\0' )
            {
                ++j;
            }
            
            *( athleteArray[ i ].name + j - 1 ) = '\0';
            
            printf( "Enter the sport of athlete %d: ", ( i + 1 ) );
            fgets( athleteArray[ i ].sport, 100, stdin );
            fflush( stdin );
            
            j = 0;
            
            while ( *( athleteArray[ i ].sport + j ) != '\0' )
            {
                ++j;
            }
            
            *( athleteArray[ i ].sport + j - 1 ) = '\0';
            
            printf( "Enter the age of athlete %d: ", ( i + 1 ) );
            scanf( "%d", &athleteArray[ i ].age );
            fflush( stdin );
            
            printf( "Enter the height of athlete %d: ", ( i + 1 ) );
            scanf( "%lf", &athleteArray[ i ].height );
            fflush( stdin );
            
            //DEBUG:
            printf( "Line %d.\n", __LINE__ );
            //ENDDEBUG
            
            putchar( '\n' );
            
            ++i;
        }
        
        sort_array_of_athletes_in_place( &athleteArray );
        
        printf( "Athletes by name, from the oldest to the youngest:\n" );
        
        i = 0;
        
        while ( i < 5 )
        {
            printf( "%s\n", athleteArray[ i ].name );
            
            ++i;
        }
    }
    
    void sort_array_of_athletes_in_place( Athlete **array )
    {
        Athlete temp;
        unsigned int i;
        unsigned int j;
        
        for ( i = 0 ; i < 4 ; ++i )
        {
            for ( j = 0 ; j < 4 ; ++j )
            {
                if ( ( *array[ j ] ).age < ( *array[ j + 1 ] ).age )
                {
                    temp = *array[ j ];
                    *array[ j ] = *array[ j + 1 ];
                    *array[ j + 1 ] = temp;
                }
            }
        }
    }

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    what compiler/operating system are you using?

    also, you need to know that fflush(stdin) is wrong.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    132
    I'm using the compiler from Microsoft. What is a safe way to clean stdin? Is it rewind( stdin ); ?
    Last edited by stdq; 02-21-2014 at 04:04 PM.

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    which compiler from microsoft? what version?

    alternatives to fflush(stdin)
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    132
    Thanks. I'm using Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    is it some version of visual studio, or are you just running it from the command line?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  7. #7
    Registered User
    Join Date
    Oct 2010
    Posts
    132
    i'm using the command-line, with the /MT option.

  8. #8
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    you might google for the command line option to enable floating point support.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  9. #9
    Registered User
    Join Date
    Oct 2010
    Posts
    132
    This page from MSDN doesn't say the solution is through an option: C Run-Time Error R6002

    =/

  10. #10
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    everything you've said points to an ancient compiler or computer. every computer that runs windows since about 1997 or 1998 has had hardware floating point support.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  11. #11
    Registered User
    Join Date
    Oct 2010
    Posts
    132
    The computer and compiler I'm using are not ancient, and I found the solution in this page: Microsoft Visual C++ Runtime Library error R6002 floating point not loaded - Visual C++ - Windows XP. Check the first post from Archean.
    Last edited by stdq; 02-21-2014 at 04:43 PM.

  12. #12
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    I couldn't find the post you mentioned. what was the solution?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  13. #13
    Registered User
    Join Date
    Oct 2010
    Posts
    132
    Quote Originally Posted by Elkvis View Post
    I couldn't find the post you mentioned. what was the solution?
    Hi, the solution was to initialize each floating-point variable before reading it from the keyboard.

  14. #14
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    I don't see how that would prevent a runtime error like that.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  15. #15
    Registered User
    Join Date
    Oct 2010
    Posts
    132
    Yeah, I don't know much about that...but the problem was solved.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. floating point not supported error
    By theju112 in forum C Programming
    Replies: 53
    Last Post: 08-18-2011, 01:42 PM
  2. fscanf() floating point error
    By folderol in forum C Programming
    Replies: 1
    Last Post: 02-19-2009, 07:51 PM
  3. Floating point error
    By ankitsinghal_89 in forum C Programming
    Replies: 9
    Last Post: 02-19-2009, 12:24 PM
  4. Floating point error: Overflow !
    By gvn in forum C Programming
    Replies: 6
    Last Post: 07-17-2003, 11:37 PM
  5. floating point error
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 01-28-2002, 01:33 AM

Tags for this Thread