I don't understand what you are asking though..
If you want to force the user to enter all 25 values, count how many have been entered and compare it to 25. If you only want to use the 24 values that have been entered, again, you only need to know many were entered..
Well, if the user has to enter a number of elements and you need to try to form an NxN matrix containing exactly that number of elements, then your criterion is met if the number entered is a perfect square.
If you are concerned about the file containing not enough number or too many numbers, then you should do two things. First, check that line 14 succeeded (if( afile ) std::cout << "I succeeded";),
and second, after line 16 check that there a no more numbers in the file by attempting to read another and checking for failure (ie, not success).
That strategy assumes that the file format is irrelevant, and there can be any number of numbers on a line.