I want to read a file into an int array , but I need to do that one element at a time. Here's what's in the file :
1000320
0110313
3333000
2033000
2203011
2000010
And here is the code :
std::ifstream fin("file.in");
for (int i=0; i<6; ++i) //rows
{
for (int j=0; j<7; ++j) //columns
{
fin>>_array[i][j];
}
}
If I would print _array[0][0] it will output everything that's on the first line. However I want to split what's in the file into rows and columns . What's the most elegant way to do this for an INT array ( I don't want to use a char array although it would be much easier . Also , I know that if I put spaces between the numbers in my file the program would read them one at a time but I want them to be like this )