friends! Programming language is C++. I have a byte matrix
unsigned char Map[Height][Width];
I initialize it with zeros.
Then I read byte matrix from text file.
Of course, text file can be larger, than my matrix is. In this case I must read information from file in such way:

Text file has extra information. I don't need it. In another case Matrix can be larger then information within text file:

In this case program must read all the information from file. The part of matrix that didn't get information from file is already initialized. It's OK.
What is the best way to read information from file to the matrix in my case?
I tried to use fgets, but it reads all information from file in consecutive way - byte after byte. But I don't need to read extra bytes. Of course, I can read file byte after byte and check counter. But I am sure that this is'nt best solution. Does a better solution exist?
The formatting of my text file is'nt relevant here. I read information from file like bytes field.
<fstream>for file IO, as opposed to the C-style functions in<cstdio>. They're a lot easier to use!