hello
i decide to first learn about file streams before learning oop concepts in c++.
want to read single digit from the textfile. actually text file contains numbers from 0 to 9. And these are 9 in a row and 3 row are there. you can think of its content as following :
123456789
012345678
010234567
what i need is that how to read first three digits from each row.Here i'm confused with what data type should i opt. i thought int
would be good but later realised that int
would read entire line as a number. Now i think that char
would be better. further it can be converted to integer using type casting.
the second point is that how read first three digits.for that i use this :
for(i=0;i<3;i++)
{
readob>>a[i];
total+=(int)a[i];
}
is that correct ?
And the last point is that after reading three digits , how to set readob
to newline.