char a = 178; — undefined behavior. If your platform uses signed representation of char, then overflow happens. On my machine result looks like that: http://imgur.com/jRIc6pC
Never use chars to store integral values. Use explicit signed or unsigned chars. In your case use unsigned chars.
Do not update screen so often. It creates terrible flickering. Use crossplatform solutions instead of windows ones (get rid of Windows.h). Stop using nonstandard outdated crap, which is not supported in modern compilers anymore (dos.h and dreaded conio.h), use C++ headers instead of C ones (cstdlib instead of stdlib.h)
Use crossplatform solutions instead of windows ones (get rid of Windows.h). Stop using nonstandard outdated crap, which is not supported in modern compilers anymore (dos.h and dreaded conio.h), use C++ headers instead of C ones (cstdlib instead of stdlib.h)
Oh really tell me one crossplatform solution.There is none!!!!
That is why it is called "undefinded behavior"! Everything can happen. It can work perfectly, it can work with errors, it can crash, it can fry your PC, it can steal your CC information or it can start armageddon. Standard allows any of these possibilities.
That is why you should avoid UB: if it works for you now, it does not means that it will work for others or even for you tomorrow.
If you change character tupe to unsigned char. your program will become well-formed and predictable.