11.3.6. A Word Transformation Map
We’ll close this section with a program to illustrate creating, searching, and iterating across a map
. We’ll write a program that, given one string
, transforms it into another. The input to our program is two files. The first file contains rules that we will use to transform the text in the second file. Each rule consists of a word that might be in the input file and a phrase to use in its place. The idea is that whenever the first word appears in the input, we will replace it with the corresponding phrase. The second file contains the text to transform.
If the contents of the word-transformation file are
brb be right backk okay?y whyr areu youpic picturethk thanks!l8r later
and the text we are given to transform ...
Get C++ Primer, Fifth Edition 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.