Annotation of mstools/samples/iostutor/exios116.cpp, revision 1.1.1.1

1.1       root        1: // exios116.cpp
                      2: // The istream get member function
                      3: #include <iostream.h>
                      4: 
                      5: void main()
                      6: {
                      7:    char line[100], ch = 0, *cp;
                      8: 
                      9:    cout << " Type a line terminated by 'x'\n>";
                     10:    cp = line;
                     11:    while ( ch != 'x' )
                     12:    {
                     13:       cin >> ch;
                     14:       if( !cin.good() ) break; // Exits on EOF or failure
                     15:       *cp++ = ch;
                     16:    }
                     17:    *cp = '\0';
                     18:    cout << ' ' << line;
                     19:    cin.seekg( 0L, ios::end ); // Empties the input stream
                     20:    cout << "\n Type another one\n>";
                     21:    cp = line;
                     22:    ch = 0;
                     23:    while ( ch != 'x' )
                     24:    {
                     25:       cin.get( ch );
                     26:       if( !cin.good() ) break; // Exits on EOF or failure
                     27:       *cp++ = ch;
                     28:    }
                     29:    *cp = '\0';
                     30:    cout << ' ' << line;
                     31: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.