data structures - Implement Scrolling text in C -


i asked question in 1 of interviews mnc recently. question

"we need display screen in text scrolls @ bottom of screen , remaining screen empty . how accomplish in c ? data structures use ..??"

any ideas please ...!

assuming console application, print new lines 24 times, puts @ bottom.

the string printed gets stored on fixed size array/vector of 81 chars (\0 terminated @ position 81), gets updated feeding routine. potentially come socket, typing, file, calling process, etc...

at feeding time (timer callbacks, when file changes, socket buffer not empty, whatever), need rotate text 1 char @ time. assuming rotation right left, copy chars 1 (not 0) till 80 i-1 preceding position. write new char on position 80.

the key graphical trick here terminate printf \r instead of \n. \r modifier return carriage: cursor returns column 0, , not go next line. allows re-print of same line.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -