why does this fail in turbo c?

L

Liux

These codes cause an error "Floating point format not linked" while running,
compiled with turbo c 2.0 and 3.0:

--------------------------

#include <stdio.h>
#include <stdlib.h>

struct type {
float a;
};

struct type x[1];

int
main(void)
{
int n = 0;
scanf("%f", &x[n].a);
return EXIT_SUCCESS;
}

--------------------------

What is odd is that when "&x[n].a" is changed to "&x[0].a", the problem
never occurs.
Whatever the size of the array x, and which value n is assigned, the error
occurs as long as i use n to replace the constant number.

I compile this with gcc and it's alright, but is it just a problem of
borland programmers? Is it something in this program that's not compatible
with The Ansi Standard?

Of course i don't want to introduce any platform based topic here, but i am
just confused about this c programming problem. Can anybody help me? Thank
you very much! :)
 
M

Martin Ambuhl

Liux said:
These codes cause an error "Floating point format not linked" while running,
compiled with turbo c 2.0 and 3.0:

Check the FAQs before posting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top