
Newbie Array/Scanf question
I am trying to write a program that has the user fill a dual
array with floating point numbers. I can not seem to be able to
get scanf to work if I use variables to represent the elements of
the array. The two code fragments below were cut and pasted from
an actual program. The first example where I use constants to
represent the array elements in the scanf statment works just
fine. The second however, where I use variables to substitute for
the array elements, does not work. I get the error message that
follows (By the way, I am using Turbo C++, v1.01, aka Second
Edition. The only library I have included is stdio.h):
float arr[5][2];
int i,j;
scanf("%f", &arr[0][0]);
printf("You entered %f", arr[i][j]);
OUTPUT Screen:
3
You entered 3.000000
***********************************
***********************************
float arr[5][2];
int i,j;
i=0;
j=0;
scanf("%f", &arr[i][j]);
printf("You entered %f", arr[i][j]);
OUTPUT Screen:
scanf : floating point formats not linked
Abnormal program termination
------------------------------------------
What am I doing wrong!!
Please reply via e-mail. Thanks!
-----------------------------------