Newbie Array/Scanf question 
Author Message
 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!


-----------------------------------



Wed, 05 May 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Newbie Array/Scanf Problem

2. Newbie with scanf question

3. questions about scanf and arrays.

4. Newbie Question: Arrays

5. Newbie Question: using delete with dynamic 2-d arrays

6. Newbie question about arrays

7. Newbie question: Making arrays bigger

8. Newbie Question: Array of Points

9. Arrays newbie question

10. ArrayList to Array -- newbie question

11. newbie question: stings, pointers and arrays

12. newbie array question

 

 
Powered by phpBB® Forum Software