May 2017
Intermediate to advanced
590 pages
17h 18m
English
In this recipe, we will see how to implement the pattern mentioned earlier for a text file. To do this, we will consider removing empty lines or lines that start with a semicolon (;). For this example, we will have an initial file called sample.dat that contains the names of Shakespeare's plays, but also empty lines and lines that start with a semicolon. The following is a partial listing of this file (from the beginning):
;Shakespeare's plays, listed by genre;TRAGEDIESTroilus and CressidaCoriolanusTitus AndronicusRomeo and JulietTimon of AthensJulius Caesar
The code samples listed in the next section use the following variables:
auto path = fs::current_path(); auto filepath = path / "sample.dat"; auto temppath = path / "sample.tmp"; ...Read now
Unlock full access