Thread: **///Re: Abnormal prg termination

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    2

    **///Re: Abnormal prg termination

    I am trying to learn C++. I have Turbo C++ 3.0 installed on a win98se machine. Whenever I try to create an arrat of floats and then scanf the values, everything works fine. But when I use an a float in a structure and then create an array of structures and try to scanf the values, I get the error msg "Abnormal program termination. floating point formats not linked". Here is the piece of code:
    ...
    ...
    Code:
    int n, i = 0;
    	struct {
    		char text[20];
    		float radius;
    		float area;
    	} circle[10];
    
    
    	printf("\nTo STOP enter END for flag\n");
    	printf("Flag: ");
    	scanf("%s", circle[i].text);
    
    	while(circle[i].text[0]!='E'||circle[i].text[1]!='N'||circle[i].text[2]!='D')
    	{
    		printf("Radius: ");
    		scanf("%f", &circle[i].radius);  //THIS WHERE THE ERROR OCCURS
    to overcome i have to declare a separate float r and use this r in scanf and then transfer the value captured to the structure element.
    can anyone please throw some light on this?
    Thanks

  2. #2
    Lead Moderator kermi3's Avatar
    Join Date
    Aug 1998
    Posts
    2,595

    Code Tags

    I am posting this because you did not use code tags on this thread. In the furture please use Code Tags. They make your code MUCH easier to read and people will be much more likely to help you if you do. And they'll be happier about helping you

    For example:

    Without code tags:

    for(int i=0;i<5;i++)
    {
    cout << "No code tags are bad";
    }

    With Code Tags:
    Code:
    for(int i=0;i<5;i++)
    {
         cout << "This code is easy to read";
    }
    This is of course a basic example...more complicated code is even easier to read with code tags than without.

    I've added code tags for you this time. They can be added by putting [code] at the beginning of your code and [/code] at the end. More information on code tags may be found on the code tag post at the top of every forum. I also suggest you take a look at the board guildlines if you have not done so already.

    This is a common first post mistake, just remember to use [code] tags in the future and you'll get much more help.

    If this is your first time posting here the welcome, and if there's anything I can do or any questions I can answer about these forums, or anything else, please feel free and welcome to PM me.


    Good Luck with your program,

    Kermi3
    Lead Moderator
    Kermi3

    If you're new to the boards, welcome and reading this will help you get started.
    Information on code tags may be found here

    - Sandlot is the highest form of sport.

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    It has to do with operator precedence. Instead of
    Code:
    scanf("%f", &circle[i].radius);
    Enclose the circle[i].radius in parens and then get the address of that ie:
    Code:
    scanf("%f", &(circle[i].radius));
    -Futura

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >It has to do with operator precedence.
    No it doesn't. Both [] and . have higher precedence than &, so no parentheses are needed. The original call was correct. The problem is a compiler bug in Turbo C++ 3.0.

    >"Abnormal program termination. floating point formats not linked"
    http://www.stratoware.com/msdos/dos-faq.html#Q0304

    -Prelude
    My best code is written with the delete key.

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    2

    THANKS

    Thanks a lot. The link u provided did help. Now after the extern stmts, the program is working fine without any errors.
    thanks a lot pal.

  6. #6
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    >It has to do with operator precedence.
    No it doesn't. Both [] and . have higher precedence than &, so no parentheses are needed. The original call was correct. The problem is a compiler bug in Turbo C++ 3.0.
    Thanks for correcting me Prelude, I'll be more conscientious and not misrepresent a guess as a fact. *embarrassed smile*

    -Futura

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. Abnormal program termination
    By Kayoss in forum C++ Programming
    Replies: 3
    Last Post: 05-16-2006, 03:29 PM
  3. abnormal program termination
    By Smiley0101 in forum C++ Programming
    Replies: 1
    Last Post: 03-02-2003, 05:04 PM
  4. abnormal program termination
    By ProLin in forum C++ Programming
    Replies: 2
    Last Post: 01-20-2002, 09:56 PM