displaying text files on ncurses mode question

Mar 15, 2017 at 9:13pm
Hi I'm trying to display text files in ncurses mode
sometimes it displays the right contents, but sometimes it displays some broken words like ?^Fms?^Fm.
I am new to ncurses... and I honestly do not know what is wrong...
Last edited on Mar 18, 2017 at 1:41am
Mar 15, 2017 at 11:26pm
The argument that you pass to printw is supposed to be a null terminated string. Try using addch instead.

1
2
printw(&x);
addch(x);

http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/printw.html#ADDCHCLASS


EDIT: You can use printw but then you have to pass a string containing the %c format specifier as the first argument and x as the second argument.

 
printw("%c", x);

printw is used the same way as printf: http://www.cplusplus.com/reference/cstdio/printf/
Last edited on Mar 15, 2017 at 11:48pm
Mar 15, 2017 at 11:52pm
Ah!! i see, it works perfectly. Thank you!
Topic archived. No new replies allowed.