Floating pointer Error in a code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sreelal

    #1

    Floating pointer Error in a code

    Dear friends,

    Please consider the following C program.


    #include<stdio. h>

    struct employee
    {
    int id;
    float sal;
    };

    main()
    {
    struct employee emp[5];
    int i=1;
    scanf("%f",&emp[i].sal);

    return 0;
    }



    When I run the follwoing C program on TurboC++ Version 3.0 on Windows
    it shows the error,

    scanf: floating point format not linked.
    Abnormal program termination

    Please tell me why this happens.

    The same code shows no error when I replace the variable 'i' in the scanf statment
    with an interger, like

    scanf("%f",&emp[1].sal);

    Please tell me what is wrong with the code.


    Lal
  • Ulrich Eckhardt

    #2
    Re: Floating pointer Error in a code

    sreelal wrote:[color=blue]
    > Please consider the following C program.[/color]
    [snipp]
    [color=blue]
    > scanf("%f",&som e_float);[/color]

    [ I hope that this simple line will already trigger the error and that you
    just neglected to make the smallest possible example from it. ]
    [color=blue]
    > When I run the follwoing C program on TurboC++ Version 3.0 on Windows
    > it shows the error,
    >
    > scanf: floating point format not linked.
    > Abnormal program termination[/color]

    Question: did you run the program or did you compile it to produce that
    output? Anyhow, it looks like support for floatingpoint operations was not
    compiled in, which makes sense when compiling for machines without an FPU,
    e.g. prehistoric personal computers.
    [color=blue]
    > Please tell me why this happens.[/color]

    Your program is (mostly) fine, so the issue is rather with your compiler.
    Take the issue to a newsgroup where that compiler is on topic.
    Maybe even better, switch to a modern compiler, DevC++(no, it's not just
    for C++) comes for free and with a modern compiler.

    Uli

    Comment

    • Does It Matter

      #3
      Re: Floating pointer Error in a code

      On Thu, 12 Aug 2004, sreelal wrote:
      [color=blue]
      > Dear friends,
      >
      > Please consider the following C program.
      >
      >
      > #include<stdio. h>
      >
      > struct employee
      > {
      > int id;
      > float sal;
      > };
      >
      > main()
      > {
      > struct employee emp[5];
      > int i=1;
      > scanf("%f",&emp[i].sal);
      >
      > return 0;
      > }
      >
      >
      >
      > When I run the follwoing C program on TurboC++ Version 3.0 on Windows
      > it shows the error,
      >
      > scanf: floating point format not linked.
      > Abnormal program termination
      >
      > Please tell me why this happens.[/color]

      Your compiler does not support floating point math by default. You need to
      read your compiler documentation to understand how to enable this.
      [color=blue]
      > The same code shows no error when I replace the variable 'i' in the scanf statment
      > with an interger, like
      >
      > scanf("%f",&emp[1].sal);
      >
      > Please tell me what is wrong with the code.
      >
      >
      > Lal
      >[/color]

      --
      Send e-mail to: darrell at cs dot toronto dot edu
      Don't send e-mail to vice.president@ whitehouse.gov

      Comment

      • Emmanuel Delahaye

        #4
        Re: Floating pointer Error in a code

        sreelal wrote on 12/08/04 :[color=blue]
        > scanf: floating point format not linked.
        > Abnormal program termination
        >
        > Please tell me what is wrong with the code.[/color]

        Nothing. It's a well known issue of BOrland C compilers. Add this at
        the top of the source file:

        #ifdef __BORLANDC__
        /* The pesky "floating point format not linked" killer hack : */
        extern unsigned _floatconvert;
        #pragma extref _floatconvert
        #endif

        --
        Emmanuel
        The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

        "C is a sharp tool"

        Comment

        • subashini

          #5
          what represents the Error :255

          hi,
          i am getting an error like
          [test.o] Error 255
          please help me to find out the problem..

          thanks in advance,
          Subashini

          Comment

          • Joona I Palaste

            #6
            Re: what represents the Error :255

            subashini <subashinicv@ct d.hcltech.com> scribbled the following:[color=blue]
            > hi,
            > i am getting an error like
            > [test.o] Error 255
            > please help me to find out the problem..[/color]

            Not knowing which compiler you are using, you might as well say "I'm
            getting some weird error" and expect us to be able to fix your code.
            Error 255 might mean anything from a missing semicolon to an internal
            bug in the compiler. We have as much chance of knowing which specific
            error it is as we have of knowing the contents of your wallet.

            --
            /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
            \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
            "The trouble with the French is they don't have a word for entrepreneur."
            - George Bush

            Comment

            • subashini

              #7
              Re: what represents the Error :255

              hi,
              i am trying to compile my C code in montavista development environment. &
              getting the error as
              "*** [test.o] Error 255"

              & i am getting no other compilation error.

              Please help me to solve the error.

              Thanks in advance,
              Subashini

              Comment

              Working...