FYI, you don't have two functions there. You just have one and it is called main(). Everything else inside main are statements. I think you wanted to say "My last FOR statement prints weirdly". Just setting the record straight here.
After the FOR statement in line 22 has finished, p has been advanced 10 times. Since it started pointing to the first element of box, it now points one element after the 10th element of box, meaning it is pointing to an invalid memory location.
Then comes the second FOR statement in line 27. This one uses p untouched, as it was left by the previous FOR statement, meaning p points to invalid memory when this second FOR starts. It gets worse: As i advances, the FOR statement continues to print more and more invalid memory locations. So what is needed? Simple: Reset p back to the first element of the array before entering the FOR statment in line 27, or switch the FOR statements: Execute the FOR statement in line 27 before the one in line 22.