read matrix input file and store it in matrix

shima's Avatar, Join Date: Apr 2009
Newbie Member
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???
asadullah.ansari's Avatar, Join Date: Jan 2008
TechCake
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