Array bounds checking
I need to include array bounds checking in the programs i write.
With strings i use the following for bounds checking :
How could I implement bounds checking on a integer array?
Here a user could enter several integers (>10) separated by whitespaces which would result in overflow. How can I check this?
your loop scans only 10 numbers - so where do you see an overflow?
It does not matter whether the user chooses to enter ten integers on one line or one on each line, there is no overflow problem.
for (i = 0; i < 10; i++)
However, for string reading, you should be taking the null character into account: