how to print a matrix on c++ using ncurses?

880 views Asked by At

I'm learning a few things about ncurses on c++ and my problem is that I want to print a matrix of strings on the screen of ncurses but some functions like printw(), addstr(), didnt let to add a thing like this....

string matrix[10][10];
for(int i=0; i < 10; i++){
    for(int j=0; j < 10; j++){
        printw("%s", matrix[i][j]);
    }
}
1

There are 1 answers

0
R Sahu On

matrix[i][j] evaluates to a std::string. You cannot use a std::string as a valid argument to printw.

Instead of

    printw("%s", matrix[i][j]);

use

    printw("%s", matrix[i][j].c_str());