Archive for 28th January 2010

UVa Online Judge runtime error

It has apparently been a long time since I had to do any kind of reading and writing from the console in C.

I was trying to work through the Minesweeper problem on the UVa Online Judge site, and my submissions kept failing with a “Runtime error”, with no explanation given as to the source of the problem. Of course, everything was working swimmingly when I was trying to run through the code as a command line application in Xcode on my Mac. Some investigation into this led me to pad my arrays and strings so that there was no chance of an array index going into areas they were not supposed to, but it was still failing.

I finally discovered the problem was that I had used an int variable in my code, but a %i instead of a %d in the scanf format string. As soon as I switched that over, the “Runtime error” went away. And I was able to move on to the “What do you mean ‘Wrong answer’???” part of my evening.

Oh, and Happy Data Privacy Day everyone.