Updating text displayed on the terminal

一笑奈何 提交于 2019-12-02 01:57:22

(some of these links, code snippets are Linux, and others are Windows)
Given your specific questions, (and assuming you do know how to write an array to the console) :

1) write the first array.
2) Then Clear The Console (or over write the console)
Something like this:

#include <stdlib.h>

void main()
{
   system("cls");
}     

Or write the following to stdout: (Linux)

write(1,"\E[H\E[2J",7);

which is what /usr/bin/clear does except it does not create another process.
Or both:

 void clear_screen()
 {
  #ifdef WINDOWS
     system ( "CLS" );
  #else
     // Assume POSIX
     system ( "clear" );
  #endif
 }  

More Options Here

3) write the next array

You can try something like this:

#include<stdio.h>

int main(void)
{

printf ("#####-----\r");
printf ("-#####----\r");

}

Not sure if I really answered your question. And if this is not your answer then you are definitely looking for something like ncurses.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!