14.5 C++14: Reading and Writing Quoted Text

Many text files contain quoted text, such as "C++ How to Program". For example, in files representing HTML5 web pages, attribute values are enclosed in quotes. If you’re building a web browser to display the contents of such a web page, you must be able to read those quoted strings and remove the quotes.

Suppose you need to read from a text file, as you did in Fig. 14.5, but with each account’s data formatted as follows:


100 "Janie Jones" 24.98

Recall that the stream extraction operator >> treats white space as a delimiter. So, if we read the preceding data using the expression in line 30 of Fig. 14.5


inClientFile >> account >> name >> balance

the first stream extraction reads 100 into the int ...

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.