Print Board String

When printing out the board, do I have to print out a String “ | “ between each number and then printing out the number every time, or is there a more convenient way like to store contents of registers in a String, so that I can create one String containing contents of registers and additional characters?

That would be one way of doing this.

Sure, a string is just a piece of memory, and you can store arbitrary stuff in memory. You could for example reserve 100 bytes on the stack and then start constructing a string in there.

However, if you want to embed / append a number in human-readable format (in)to a string, you would need to convert it into such a format. In other words, you would need to write code that divides the number by 10, repeatedly, and then displays the resulting digits in ASCII.

This is certainly possible, and how I solved this exercise (back when I was a student). I would, however, not recommend this.

Again, this is not actually as convenient as you would imagine.

3 Likes