+ 3

If I print something ,set console's cursor position to the beginning again, and print something again, what will happen?

Will the data be overwritten on or the old data will get erased?

24th May 2017, 4:55 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
6 Réponses
+ 12
Console display is merely temporary. For old data, being overwritten and being erased is the same.
24th May 2017, 5:01 AM
Hatsy Rei
Hatsy Rei - avatar
+ 9
@Jay quite the good idea to have a struct/function which does all that. Gave me an idea. :>
24th May 2017, 5:58 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
@Hatsy Rei I thought it may be something like - w over h (what I assumed as overwriting) in printing hello, then world...
24th May 2017, 5:07 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
It is just a CHAR_INFO array. I send all my strings to that first. I created a struct that holds the string, colour info and x y positions then feed this into a writetobuffer function in my window class. Then when it is time to present the buffer to the screen I pass the buffer to the console via WriteConsoleOutputA
24th May 2017, 5:34 AM
jay
jay - avatar
+ 3
thanks. I learnt about buffering when I was learning SDL and figured I would try to implement it via window.h tried many things like map and pair to link color info to the string before I was omg idiot a struct was made for exactly this lol
24th May 2017, 6:07 AM
jay
jay - avatar
+ 2
I have been using a buffer to display text to the screen. If the buffer is not cleared and new data is inserted in the same position it will overwrite. But if the string is not as long as the previous string it will also include characters from the old string. I.e first string = Hello World Second string = cool result = coolo World I use a buffer to prevent flickering when adding new data to the screen.
24th May 2017, 5:21 AM
jay
jay - avatar