c - Updating/Refreshing text displayed on the terminal -


I am trying to create a life program game in C, but I am not very familiar with the process of updating The output displayed on the terminal.

So, for example, I have a 2d char array, where each element would have '#' or '-'. I'll print this array on the screen, but whenever a new change happens, instead of printing the new 2D array every time I want to overwrite the old array in the terminal with the new state.

I have seen the ways to do this, but have not been fortunate enough. I have found that there is a cart return in the printf function (\ r), but hopefully someone has the most to do this Can say good way

Specifically, how can I print a 2D array, change the elements of the array, and print the new array at the top of the old one, that is, overwrite it.

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

1) Write the first arrow. 2) Then clear the console (or write more console) Something like this:

  #include & lt; Stdlib.h & gt; Zero main () {system ("cls"); }   

or write the following at stdout: (linux)

  (1, "\ e [h \ e [2J", 7];   

Which is / usr / bin / is explicit, besides this it does not make another process.
or both:

  zero clear_screen () {#ifdef Windows System ("CLS"); #else // The eclipse system ("clear"); #endif}   

3) Write the next array

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -