In article <40********@buckaroo.cs.rit.edu>,
Jennica Humphrey <jj*****@STOPSPAM.rit.edu> wrote:
while ( inFile >> name >> value ) { // read lines
cout << "Name: " << name << " Value: " << value;
}
The file reads one word at a time, which appears to be delineated by
whitespace or a newline. How do I change the delineator, for example,
using '=' instead of ' '?
Use getline() instead of the >> operator. It allows you to specify a
terminator character in place of the default '\n'. For example, if you
have three tab-delimited fields per line (and each line is terminated by a
newline):
std::string field1, field2, field3;
while (getline (infile, field1, '\t') && getline (inFile, field2, '\t')
&& getline (inFile, field3))
{
cout << field1 << '\t' << field2 << '\t' << field3 << endl;
}
--
Jon Bell <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA