• C

reading numbers from files into matrix then printing

Hi. okay, last week for my C course,i had to prompt a user for 20int (one at a time), which were scanned into an array.
so for that, i got:
SIZE = 20;
int a[20];
int i;

for(i=0; i<SIZE; i++){
  printf("prompt here");
  scanf("%d\n", a[i]0;
for this week, we're supposed to write a program, using a read function and a print funtion to read a set of numbers from a file (entered by user) into a 5x5dim array and then print the contents of the matrix. i saw something online that seemed to be stating 2 scan statements (like above) simultaneously. I want to be able to scan in and print out as efficiently as possible. i'm thinking of nesting 2 "for" statements, something like:

for(i=0; i<SIZE; i++){
 for(j=0; j<SIZE; j++){
   fscan(fileName, "%f", &a[i][j]);  //#s in this one are floating.// then using the same to print.
please help!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>   fscan(fileName, "%f", &a[i][j]);  //#s in this one are floating.// then using the same to print.
It should be
fscanf(fileName, "%f", &a[i][j]);  //#s in this one are floating.// then using the same to print.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cooling9999Author Commented:
yea. typo. sorry.

is that all i need though?
do i need to scan in the file name or something to get the # in the file?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.