Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.robertl/eb77.C

raw
1 // { dg-do run }
2 // { dg-skip-if "requires hosted libstdc++ for iostream" { ! hostedlib } }
3 #include <iostream>
4 #include <sstream>
5
6 using namespace std;
7
8 int
9 main(int, char* [])
10 {
11 stringstream s;
12
13 s << "line 1\nline 2\n\nline 4";
14 s << std::ends;
15
16 int nLine = 0;
17
18 while( true ) {
19 char line[100];
20 s.get(line, 100);
21
22 if( ! line ) {
23 break;
24 }
25
26 ++nLine;
27 std::cout << nLine << ": " << line << std::endl;
28
29 if( nLine > 10 ) { // stop infinite loop
30 break;
31 }
32 }
33 return 0;
34 }