There is UB in the program due to access to array element out of array bounds.
// trying to access b[5] whereas size of array b is 5.
// The last element you can work with is b[4].
for (int i = 1; i <= 5; i++)
need to be fixed to:
for (int i = 1; i <= 4; i++)
or even (start with 0):
for (int i = 0; i <= 4; i++).
Comments
Leave a comment