Thread: Run Time Error

  1. #1
    Unregistered
    Guest

    Angry Run Time Error

    Why I will get a run time error message?Can some body pls show the wrong place?

    #include<stdio.h>
    #define MAX_STU 50

    typedef struct{
    int id;
    double gpa;
    } student_t;

    void scan_student (student_t *s)
    {
    printf("\nEnter student id>");
    scanf("%d", &s->id);
    printf("\nEnter student gpa>");
    scanf("%lf", &s->gpa);
    }

    main()
    {
    student_t stulist[MAX_STU];
    int i;

    for(i=0; i<MAX_STU; ++i)
    scan_student (&stulist[i]);

    for(i=0; i<MAX_STU; ++i)
    printf("%d\n", stulist[i].id);

    }

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Works fine here. What's the error message you are getting?

  3. #3
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680
    I got the same run-time error.
    Don't know why but I solved it by changing %lf to %ld or scanning the gpa in a tmp variable:
    Code:
    scanf("%ld ", &s->gpa);
    
    or
    
    void scan_student (student_t *s) 
    {
      double tmp; 
      printf("\nEnter student id>"); 
      scanf("%d", &s->id); 
      printf("\nEnter student gpa>"); 
      scanf("%lf", &tmp); 
      s->gpa = tmp;
    }
    b.t.w. shaik786, the error message is:

    runtime error R6002
    - floating point not loaded

    Using Windows NT, VC++ 6.0

  4. #4
    Unregistered
    Guest
    why this will happen? can advance pls explain?

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    www.rt.com/man/ Lookup scanf(), then look at the format modifiers it accepts.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM