addnstr, addstr, mvaddnstr, mvaddstr, mvwaddnstr, mvwaddstr, waddnstr, or waddstr Subroutine
Purpose
Adds a string of multi-byte characters without rendition to a window and advances the cursor.
Library
Curses Library (libcurses.a)
Syntax
#include <curses.h>
int addnstr(const char *str,
int n);
int addstr(const char *str);
int mvaddnstr(int y,
int x,
const char *str,
int n);
int mvaddstr(int y,
int x,
const char *str);
int mvwaddnstr(WINDOW *win,
int y,
int x,
const char *str,
int n);
int mvwaddstr(WINDOW *win,
int y,
int x,
const char *str);
int waddnstr(WINDOW *win,
const char *str,
int n);
int waddstr(WINDOW *win,
const char *str);
Description
These subroutines write the characters of the string str on the current or specified window starting at the current or specified position using the background rendition.
These subroutines advance the cursor position, perform special character processing, and perform wrapping.
The addstr, mvaddstr, mvwaddstr and waddstr subroutines are similar to calling mbstowcs on str, and then calling addwstr, mvaddwstr, mvwaddwstr, and waddwstr, respectively.
The addnstr, mvaddnstr, mvwaddnstr and waddnstr subroutines use at most, n bytes from str. These subroutines add the entire string when n is -1.
Parameters
Item | Description |
---|---|
Column | Specifies the horizontal position to move the cursor to before adding the string. |
Line | Specifies the vertical position to move the cursor to before adding the string. |
String | Specifies the string to add. |
Window | Specifies the window to add the string to. |
Return Values
Upon successful completion, these subroutines return OK. Otherwise, they return ERR.
Examples
- To add the string represented by xyz to the stdscr at
the current cursor location, enter:
char *xyz; xyz="Hello!"; addstr(xyz);
- To add the "Hit a Key" string to the stdscr at the coordinates
y=10, x=5, enter:
mvaddstr(10, 5, "Hit a Key");
- To add the xyz string to the user-defined window my_window at
the coordinates y=10, x=5, enter:
mvwaddstr(my_window, 10, 5, "xyz");
- To add the xyz string to the user-defined string at the
current cursor location, enter:
waddstr(my_window, "xyz");