O'Reilly logo

Beginning C++ Programming by Richard Grimes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Standard Library

In this example, we will develop a simple parser for Comma Separated Value (CSV) files. The rules we will follow are as follows:

  • Each record will occupy one line, and newline indicates a new record
  • Fields in the record are separated by commas, unless they are within a quoted string
  • Strings can be quoted using single (') or double quotes ("), in which case they can contain commas as part of the string
  • Quotes immediately repeated ('' or "") is a literal, and a part of the string rather than a delimiter of a string
  • If a string is quoted, then spaces outside of the string are ignored

This is a very basic implementation, and omits the usual requirement that quoted strings can contain newlines.

In this example, much ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required