Moving the reader one space over

Writing a program for class to read from a file and output, and needing a little help.


Data file looks like:
Smith Eleanore 110/73

Get looks like:
myfile >> lastname >> firstname>> systolic >> diastolic;

cout looks like:
cout << lastname << ", " << firstname << " has " << systolic << "/" << diastolic <<endl;

Output looks like:
Smith, Eleanore has 110/12297192 (The number past the "/" changes.)

Supposed to looks like:
Smith, Eleanore has 110/73


I'm not certain, but I believe I need to get the read marker(or whatever you call it) moved over one space, and I'm not sure how to do that. Any help or hints appreciated.
Last edited on
closed account (zb0S216C)
I see no extraction operation to remove the '/' within the file. So when it comes to reading the last part of the file, 110 is extracted, followed by '/', and then 73. Chances are, the '/' is being read as an integer.

Don't forget that std::istream::operator >>() is a formatted operator.

Wazzak
I've gotten it figured out now, thanks a bunch.
Last edited on
Topic archived. No new replies allowed.