0

I want to show in console a matrix that starts out like this:

int matrix_1[2][3]= {{0, 0, 0}
                     {0, 0, 0}};`

Shown in console like

0 0 0
0 0 0

But then, just like in flash games where the Loading %1 updates to Loading %5 without scrolling down, I want the matrix shown in the console to update to this

1 2 3
4 5 6

In code like

int matrix_2[2][3]= {{1, 2, 3}
                     {4, 5, 6}};

I guess I can use \r, but I don't understand how to superpose matrix_2 over matrix_1, I've tried it and it doesn't work. Do i have to use curse.h library or can I superpose the matrix in another way?

I'm new at this aspect of C programming..

Benjy Kessler
  • 7,356
  • 6
  • 41
  • 69
  • possible duplicate of [Is there go up line character? (Opposite of \n)](http://stackoverflow.com/questions/11474391/is-there-go-up-line-character-opposite-of-n) – Benjy Kessler May 09 '15 at 23:32

1 Answers1

1

Its not that easy to do that in C. You can have a look at Ncurses library though. There Moving the cursor section can actually help.

You can also use the following line right before the printf lines for printing the matrix_2. That will fulfill your requirement in "not a good way", I think.

system("clear");

Ncurses will be better.

Surajeet Bharati
  • 1,363
  • 1
  • 18
  • 36