Today, I was reading about structures in Let Us C (on Goodreads). I am confused a bit about the usage of linkfloat(). Without its use, I am able to write programs on structures having float type data members.
I am programming using the ideone online compiler.
int main()
{
struct book
{
char name;
float price;
};
struct book b;
scanf("%c %f",&b.name,&b.price);
printf("%c %f",b.name,b.price);
return 0;
}
/*linkfloat()
{
float a=0,*b;
b=&a; //cause emulator to be linked
a=*b; //suppress the warning: variable not found
}*/
here is the link:
http://ideone.com/peL5q
Even without the use of linkfloat, the program compiles and outputs correctly. So what purpose does it serve?
linkfloatis an anachronism from the days of Turbo C when early Intel CPUs did not have hardware floating point support (1980s) and instead relied on software floating point libraries which needed to be linked into any executable that required floating point support. You do not need such anachronisms with any reasonably modern x86 CPU and C compiler (anything from the last 20 years or so). I suggest you ditch any bad/outdated text books or course material which still refers to such things (the books by Kanetkar which are still in use at some Indian colleges are particularly bad in this respect)