#include <stdio.h>
void linkfloat();
int main()
{
struct book
{
char name ;
float price ;
int pages ;
} ;
struct book b[100] ;
int i ;
for ( i = 0 ; i <= 99 ; i++ )
{
printf ( "\nEnter name, price and pages " ) ;
fflush(stdin);
scanf ( "%c %f %d", &b[i].name, &b[i].price, &b[i].pages ) ;
}
for ( i = 0 ; i <= 99 ; i++ )
printf ( "\n%c %f %d", b[i].name, b[i].price, b[i].pages ) ;
return 0;
}
linkfloat( )
{
float a = 0, *b ;
b = &a ; /* cause emulator to be linked */
a = *b ; /* suppress the warning - variable not used */
}
I failed to figure out the use of fflush(stdin) in the code.I tried to google about what it means but failed to know its meaning and its use..can anyone please help me and tell me for what it is used.i even didnt understand the use of linking floating point formats.i failed to guess what does linking of floating point format means...please help me out with the following...
I don't see fflush() in the code anywhere, and the typeless function linkfloat() on line 18 makes me suspect this is a very old version/nonstandard of C. I don't even understand what linkfloat() is supposed to do; "linking the emulator" makes no sense to me, as the code seems to be just a fancy no-op.
With regard to the linkfloat function - a quick google turned up this explanation - I can't confirm it's correctness - (but it sure looks like you have a very old book)
Did your book happen to say what this program is meant to do? I find it strange that the function "linkfloat()" doesn't actually get used anywhere in the program, it's just defined and then left out. Weird.
linkfloat is 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)
If there's any substance to this, it implies that the book used by the OP is positively antiquated and should probably be put in a museum.