I am making a chat application for my homework which runs within a Linux Terminal. So, I need to take from the user some input and display the output from all the users as well in a well organized manner. So, I made two threads. One thread have a cin command and the other thread is having a display function which basically uses printf to sequentially print the 开发者_开发知识库chat messages.
But the problem is that I am not able to give the input properly because as soon as I start writing something on the terminal it moves the focus/cursor to the next line it prints.
One way that I was able to figure out is use gotoXY function in the thread with the cin statement. But what I was not able to figure out in this way is how to print the chat messages sequentially.
Simulate a scrolling window? As text is received, store the last 10 lines. Then loop through the last 10 lines of text received and print them on lines 1-10 on the screen using gotoxy.
精彩评论