I'm using the pdcurses library and I'm writing a function which moves a line on the screen up one. This involves copying the current line and then pasting it above. The problem is that the curses function for printing whole lines,
The printw() functions add a formatted string to the window at
the current or specified cursor position. The format strings are
the same as used in the standard C library's printf(). (printw()
can be used as a drop-in replacement for printf().)
winchnstr(w, p, 200); //obtain the line
clrtoeol(); //remove the line
wmove(w, y-1, x); //move up a line
clrtoeol(); //erase the line
wprintw(w, p); //print the new line
printf to accept your string as it is, use the format specifier
%s and pass your string as an argument.
printf arguments are not subject for format processing. In case of strings, the bytes are simply copied over to the destination buffer.
printf("%s", "My string with % signs");
In case your string isn't zero-terminated, you can pass a length before the string to printf if you use the
%*s format specifier:
printf("%*s", 5, "ab%cdefghi"); // prints "ab%cd"
Note that the length argument must be of type