Tools.h++ Manual
104011 Tandem Computers Incorporated 5-7
5
Other functions allow finer tuning of
RWCString
input. Function
readline()
allows strings separated by newlines. It has an optional
parameter controlling whether whitespace is skipped before storing characters.
Here’s an example showing the difference:
Program input:
line 1
line 5
#include <rw/cstring.h>
#include <iostream.h>
#include <fstream.h>
main()
{
RWCString line;
{
int count = 0;
ifstream istr(“testfile”);
while (line.readLine(istr)
// Use default value: skipwhitespace
count++;
cout << count << “ lines, skipping whitespace.\n”;
}
{
int count = 0;
ifstream istr(“testfile”);
while (line.readLine(istr, FALSE)
// NB: Do not skip whitespace
count++;
cout << count << “ lines, not skipping whitespace.\n”;
}
return 0;
}