1fgetws(3) Library Functions Manual fgetws(3)
2
3
4
6 fgetws - read a wide-character string from a FILE stream
7
9 Standard C library (libc, -lc)
10
12 #include <wchar.h>
13
14 wchar_t *fgetws(wchar_t ws[restrict .n], int n, FILE *restrict stream);
15
17 The fgetws() function is the wide-character equivalent of the fgets(3)
18 function. It reads a string of at most n-1 wide characters into the
19 wide-character array pointed to by ws, and adds a terminating null wide
20 character (L'\0'). It stops reading wide characters after it has en‐
21 countered and stored a newline wide character. It also stops when end
22 of stream is reached.
23
24 The programmer must ensure that there is room for at least n wide char‐
25 acters at ws.
26
27 For a nonlocking counterpart, see unlocked_stdio(3).
28
30 The fgetws() function, if successful, returns ws. If end of stream was
31 already reached or if an error occurred, it returns NULL.
32
34 For an explanation of the terms used in this section, see at‐
35 tributes(7).
36
37 ┌────────────────────────────────────────────┬───────────────┬─────────┐
38 │Interface │ Attribute │ Value │
39 ├────────────────────────────────────────────┼───────────────┼─────────┤
40 │fgetws() │ Thread safety │ MT-Safe │
41 └────────────────────────────────────────────┴───────────────┴─────────┘
42
44 C11, POSIX.1-2008.
45
47 POSIX.1-2001, C99.
48
50 The behavior of fgetws() depends on the LC_CTYPE category of the
51 current locale.
52
53 In the absence of additional information passed to the fopen(3) call,
54 it is reasonable to expect that fgetws() will actually read a multibyte
55 string from the stream and then convert it to a wide-character string.
56
57 This function is unreliable, because it does not permit to deal
58 properly with null wide characters that may be present in the input.
59
61 fgetwc(3), unlocked_stdio(3)
62
63
64
65Linux man-pages 6.05 2023-07-20 fgetws(3)