ad-si/RosettaGit

Code works fine but only '.' and ':' characters show up on the cuboid.

ygator opened this issue · 0 comments

Issue on page "Draw a cuboid":

This is because the line:
putchar(shades[(int)(b * (sizeof(shades) - 2))]);
is using sizeof(shades) which returns the size of a const char *. On my system it is 4.
shades points to the string ".:!*oe&#%@" which has 10 characters in it.
Therefore you want strlen(shades) or 10 instead of the sizeof(shades). I also do not
know why you are subtracting 2. The line should just be:
putchar(shades[(int)(b * 10)]);
though I guess b can be 1 technically so maybe you want
putchar(shades[(int)(b * (10-1))]);