Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
27.istream.getline.stdcxx-67.cpp
Go to the documentation of this file.
1
29#include <cassert>
30#include <sstream>
31
32int main ()
33{
34 std::istringstream strm ("\n\n");
35
36 char s [3] = { 'x', 'y', 'z' };
37
38 strm.getline (s, 0);
39
40 // 27.6.1.3, p17, bullet 2:
41 // Characters are extracted and stored until c == delim for the next
42 // available input character c.
43
44 assert (strm.goodbit == strm.rdstate ());
45 assert (1 == strm.gcount ());
46 assert ('x' == s [0]);
47 assert ('y' == s [1]);
48 assert ('z' == s [2]);
49
50 strm.getline (s, 1);
51
52 // 27.6.1.3, p17, bullet 3:
53 // Characters are extracted and stored until (n - 1) characters
54 // are stored (in which case the function calls setstate(failbit)).
55 // p20:
56 // In any case, it then stores a null character (using charT()) into
57 // the next successive location of the array.
58
59 assert (strm.goodbit == strm.rdstate ());
60 assert (1 == strm.gcount ());
61 assert ('\0' == s [0]);
62 assert ('y' == s [1]);
63 assert ('z' == s [2]);
64
65 strm.clear ();
66 strm.getline (s, 2);
67
68 // 27.6.1.3, p17, bullet 1:
69 // Characters are extracted and stored until end-of-file occurs on
70 // the input sequence (in which case the function calls setstate(eofbit))
71 // p20:
72 // In any case, it then stores a null character (using charT()) into
73 // the next successive location of the array.
74
75 assert ((strm.eofbit | strm.failbit) == strm.rdstate ());
76 assert (0 == strm.gcount ());
77 assert ('\0' == s [0]);
78 assert ('y' == s [1]);
79 assert ('z' == s [2]);
80
81 return 0;
82}
#define s
#define strm
Definition 17.names.cpp:549
#define assert(expr)
Definition _cassert.h:40