# Thread: fscanf at "dynamic" matrix

1. ## fscanf at "dynamic" matrix

hi everyone.. im rookie at programming and i have got a question..
i ve got this txt file.:
i want to read all this file and print it. the problem is that the number of collumns isnt standard, but depends from n (the 1st number of this file )
as i said im new at programming and i cant find a solution for this problem..

PS..
i know that one of the rule of the forum is to not answer to this kind of question by givving all the code but ... i havent any hope to find a solution.....

2. Originally Posted by jimbakl
i know that one of the rule of the forum is to not answer to this kind of question by givving all the code but ... i havent any hope to find a solution.....
Of course you do! Get a damm book about C and start reading, or read the tutorials of this site.

PS: Go to a greek forum. Most idiots there hand over the code to you without question. ( Σόρρυ )

3. sorry countryman

4. Code:
```6		                       //comment  example, n=6 it could be 10 or 2, show the number of clients
0 200 80 140 100 75                   // is a matrix with n+1 rows and n collumns
0 26.9 50.2 49.3 46.3 12
26.9 0 72.4 74.7 68.7 70.4
50.2 72.4 0 54.7 4 75
49.3 74.7 54.7 0 52.2 25.2
46.3 68.7 4 52.2 0 71.7
12 70.4 75 25.2 71.7 0```
Start by looking at your file... What do you see?

Ok first line is a single integer which happens to be 6
After that every line has how many numbers?

So the first line tells you what?

Can you figure out from the file how big your array needs to be?
Can you figure frome the file what kind of values it contains?
Can you figure out from the file how you might read in the values?

What choices do you have for storing this array?

Hint: Look for simple answers... this one isn't hard.

5. Well the first step is to try and write the code based on the assumption of a small value of n

Say
double matrix[10][10];

Can you write the code to read a file into such a matrix?

If you can't then there are some basic things to sort out long before we get to the "dynamic" part of the problem.

Don't worry, the code you write for the fixed array will still work with a dynamic array, so you're not going to waste a lot of time on code you won't use.