Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
27.istream.getline.stdcxx-59.cpp
Go to the documentation of this file.
1
29#include <cassert>
30#include <sstream>
31
32int main ()
33{
34 // According to lib.istream.unformatted, p20:
35 // "[getline...] stores a null character (using charT())
36 // into the next successive location of the array."
37
38 std::istringstream strm;
39
40 strm.setstate (strm.failbit);
41
42 char s [3] = { 'x', 'y', 'z' };
43 strm.getline (s, 2);
44
45 assert ('\0' == s [0]);
46 assert ('y' == s [1]);
47 assert ('z' == s [2]);
48
49#ifndef _RWSTD_NO_WCHAR_T
50
51 std::wistringstream wstrm;
52
53 wstrm.setstate (wstrm.failbit);
54
55 wchar_t ws [3] = { L'x', L'y', L'z' };
56 wstrm.getline (ws, 2);
57
58 assert (L'\0' == ws [0]);
59 assert (L'y' == ws [1]);
60 assert (L'z' == ws [2]);
61
62#endif // _RWSTD_NO_WCHAR_T
63
64 return 0;
65}
#define s
#define strm
Definition 17.names.cpp:549
#define assert(expr)
Definition _cassert.h:40