I wrote a C ++ program to input values for an NxN matrix. Typically, you can enter an integer and press the Return key for NxN times. But I would like the cursor to move the tab length for each value entered by the user. This is done for the line, and then a new line is displayed for input for the next line. I know the use of curses.h for such an implementation, but have not figured out how to implement it.
Thank.
#include <ncurses.h>
#include <iostream>
using namespace std;
int main()
{
char ch[10];
int array[4][4];
initscr();
raw();
keypad(stdscr, TRUE);
echo();
printw("Enter elements a 4x4 array: \n");
for(int i=0;i<4;i++) {
for(int j=0 ; j<4; j++) {
getstr(ch);
array[i][j]=atoi(ch);
addch('\t');
refresh();
}
addch('\n');
}
getch();
endwin();
return 0;
}
source
share