Reading from .txt file into two dimensional array in c++ -
so either i'm complete idiot , staring me right in face, can't seem find resources can understand on google, or here.
i've got text file contains several lines of integers, each integer separated space, want read these integers array, each new line first dimension of array, , every integer on line saved second dimension.
probably used worst terminology explain that, sorry.
my text file looks this:
100 200 300 400 500 101 202 303 404 505 111 222 333 444 555
and want resulting array this:
int myarray[3][5] = {{100, 200, 300, 400, 500}, {101, 202, 303, 404, 505}, {111, 222, 333, 444, 555}};
i believe that
istream inputstream; int myarray[3][5]; for(int = 0; < 3; i++) for(int j = 0; j < 5; j++) istream >> myarray[i][j];
should need.
Comments
Post a Comment