read matrix input file and store it in matrix

Newbie Member
16Apr2009,16:44   #1
shima's Avatar
hi,

i having problem in reading input value in matrix form and store it in matrix.

below is a sample of my input file (ref.txt)

A1 A2 A3 A4 A5 A6 A7 A8
q1 1 0 0 1 0 1 1 0
q2 0 1 1 0 1 0 0 0
q3 0 0 0 1 0 0 1 1
q4 0 1 0 0 0 1 0 1
q5 1 0 0 0 0 0 1 0
q6 0 0 1 0 1 0 0 1

how should i read this kind of input???
TechCake
17Apr2009,09:46   #2
asadullah.ansari's Avatar
take two loop one is for row means end of file and other is for column means end of line...
and skip white space(according to your text file)...
Example:
Code:
for i=0 to EOF
   for j=0 to EOL
         Skip according to your file which character  you have to skip menas like white space
         Mat[i][j]= read contents by file Pointer