C/Floating point in Structure
Expert: Narendra - 9/3/2004
QuestionI have a problem regarding the floating point. If I used arrays as floating point it accept. for ex- float a[5];
But when I defined floating point array inside the structure and used scanf it gives an error scanf :floating point formats not linked
If I initialize the structure then the member variable which I had declared as floating point it accepts.
But while using scanf it doesn't. Will you please help me in this regard. I am using Turbo C compiler.
for ex :
typedef struct{
char name[10];
int age;
float percentage[5];}student;
main()
{
student s[3];
for (i=0;i<3;i++)
{ printf("%f",a[i]);}
}
if I initialize as
student s[3]={{"Ram",23,34.5},
{"Rama",21,25.6},
{"Ravi",20,65.7}};
Then the value of floating point is accepted and it display without any error.
Expect the proper guidance from you.
Thanks in anticipation
Meenakshi
AnswerHi,
Your problem is not clear to me. It looks like, you are getting compilation errors for a statement which is reading array. If you show me the code that gave you error, then I can suggest something. Do post the code, for which you got compilation error.
-ssnkumar