hi,

#include<stdio.h>
#include<conio.h>

struct cricket
{
char name[10];
char teamname[10];
float batavg;
}c1[5];

void main()
{
int i,j;
clrscr();


for(i=0;i<2;i++)
{
printf("Enter name:");
scanf("%s",c1[i].name);

printf("Enter Team Name:");
scanf("%s",c1[i].teamname);

printf("Enter Batting avg:");
scanf("%f",&c1[i].batavg);
}
for(i=0;i<2;i++)
{
printf("%s\n",c1[i].name);
printf("%s\n",c1[i].teamname);
printf("%f\n",c1[i].batavg);

}
getch();
}

When i running the above program which gives me following Error when scaning float value!

Enter name:keval
Enter Team Name:kkk
Enter Batting avg: scanf : floating point formats not linked
Abnormal program termination

But when i change float to int type it works fine but not with float Why?????
Pls some one help me to solve this error!thanks...

U using older borland compiler may be ..
It worked totally fine @ me ..
I compiled in Dev-C++ it worked fine but not working in borland ..

I m using Borland C++ Compiler Versiuon 3.0

Check with Dev-C++ .. Worked fine for me ..

floating point constant cannot be stored in structure through scanf,so write in the following way
float x;
scanf("%f",&x);
c1[i]-->batavg=x;

floating point constant cannot be stored in structure through scanf

Sorry, but that's incorrect.

this solution is not efficient.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.