Hi,
I created a structure which has 2 char arrays and 1 float variable. When trying to input data into the float variable the program crashes. On the output screen I can see the following error.
Following is the code:Code:scanf : floating point formats not linkedAbnormal program termination.
I am using Turbo C compiler. I cannot understand what I am doing wrong. Please help me.Code:#include<stdio.h> #define NAME_LIMIT 100 #define TEAM_LIMIT 20 #define NO_OF_PLAYERS 10 struct cricket { char name[NAME_LIMIT]; char team[TEAM_LIMIT]; float bat_avg; }; typedef struct cricket cricket; void getS(char [], int); void main() { cricket player[NO_OF_PLAYERS]; int i; clrscr(); printf("Please enter details of %d players:-",NO_OF_PLAYERS); for(i=0;i<NO_OF_PLAYERS;i++) { printf("\n\nPlayer %d:-",i+1); printf("\nPlayer Name: "); getS(player[i].name,NAME_LIMIT); printf("\nTeam: "); getS(player[i].team,TEAM_LIMIT); printf("\nBatting Average:"); scanf("%f",&player[i].bat_avg); } } void getS(char str[], int max) { int i=-1; do { str[++i] = getche(); } while(i<max-1 && str[i] != '\n' && str[i] != '\r'); str[++i] = '\0'; }
Thank you,
-Sreejit



LinkBack URL
About LinkBacks



CornedBee
I used to be an adventurer like you... then I took an arrow to the knee.