Hi all, I'm writing a simple program that displays information and I've run into a bug where my colour bleeds outside of where it should. I've replicated the bug with the following code:
If you type 'frog' and press enter 3 times, the word "FROG!" is properly displayed with a green background and bright green text (might have to scroll up to see it). If you type frog 4 times, the background colour bleeds outside of the line. It only seems to modify the 4th frog input and afterward, the previous are unaffected. Also, the bug only seems to happen when there are many lines of cout in the code (like above). Ideas? Any help would be greatly appreciated! Thanks in advance!
I compiled your code in MS Visual 2012 Express, and everything looked fine to me. Each word was in the correct colors, and each section of blah's was good. What compiler are you using? If I have that compiler, I'll try again, with it.
It's probably not the compiler, but the header files. And most likely not much you can do about it, except not have too many words outputted after you change colors.
Were you able to run the 'Frog colors' program? If so, did it show the same bleed-through as yours? If it did, then it may be a problem with way your computer processor handles the colors, and not the compiler or headers.
I also compiled it with Dev-C++ v5.6.2, and it ran fine also. It uses the MinGW compiler.
I get similar results as your Mary Magdalene with code::blocks aswell. Basically it only happens after enter frog correct 11 times and keep happening after.
I checked if any of the setConsoleTextAttribute failed but none of them failed. I would say its not being buffered but you are using endl so that shouldn't be the case. Someone with more knowledge in windows might know.
I'm not receiving any errors in the logs when compiling the code above. Any other ideas?
The errors it was suggested you check for would not happen when compiling code. The suggestion was to check return values from functions to see if errors were occurring.
For instance, in the following we check for errors in the API calls:
I read where giblit said it happened for him after typing in frog 11 times, so I tried it, also. And yes, I was getting the same results as him, with my program. Weird. I had only tested the program with 5 inputs, so never saw the bleed-through before.
Okay, I fooled around with the code a bit more. I added a color change to light gray on black, and then the newlines. Then changed the color to what was to be printed. Even after 14 typed 'frog's, I'm still not getting any bleed-through.