Last change
on this file was 2214e81, checked in by Peter A. Buhr <pabuhr@…>, 3 months ago |
move word test programs under tests directory
|
-
Property mode
set to
100644
|
File size:
734 bytes
|
Rev | Line | |
---|
[38e17b0] | 1 | #include <string.hfa>
|
---|
| 2 | #include <fstream.hfa>
|
---|
| 3 |
|
---|
| 4 | int main() {
|
---|
| 5 | string line;
|
---|
| 6 | charclass alpha{ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" };
|
---|
| 7 | size_t i;
|
---|
| 8 |
|
---|
| 9 | try {
|
---|
| 10 | for ( ;; ) {
|
---|
| 11 | sin | getline( line );
|
---|
| 12 | for ( ;; ) { // scan words off line
|
---|
| 13 | size_t posn = exclude( line, alpha ); // find position of 1st alphabetic character
|
---|
| 14 | if ( posn == len( line ) ) break; // any characters left ?
|
---|
| 15 | line = line( posn ); // remove leading whitespace
|
---|
| 16 | posn = include( line, alpha ); // find position of 1st non-alphabetic character
|
---|
| 17 | sout | line( 0, posn ); // extract word from start of line
|
---|
| 18 | line = line( posn ); // delete word from line
|
---|
| 19 | } // for
|
---|
| 20 | } // for
|
---|
| 21 | } catch( end_of_file * ) {}
|
---|
| 22 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.