bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 18.3, Problem 19STE

Explanation of Solution

Modified code:

The modified code for given display 18.17 is shown below:

//Header file

#include <iostream>

#include <list>

#include <algorithm>

//std namespace

using std::cin;

using std::cout;

using std::endl;

using std::list;

using std::find;

//Min function

int main( )

{

        /* Declare line in "list" template */

        list<char> line;

        /* Display prompt statement */

    cout << "Enter a line of text:\n";

        //Declare variable for "next"

        char next;

    /* Read text from user */

        cin.get(next);

        /* If "next" is not equal to "\n" */

        while (next != '\n')

        {

            /* Insert the character to list */

            line.push_back(next);

            /* Read the next character */

            cin.get(next);

        }

  /* Declare char varaible "where" in constant iterator */

        list<char>::const_iterator where;

  /* where is located at the first occurrence of 'e' in line.*/

        where = find(line.begin( ), line.end( ), 'e');

  /* Declare char variable "p" in constant iterator */

    list<char>::const_iterator p;

        /* Display statement */

  cout << "You entered the following before you entered your first e:\n";

  /* Using "for" loop, display located at the first occurrence of 'e' in line */

        for (p = line...

Blurred answer
Students have asked these similar questions
In Java,  Explain when it might be preferable to use a map instead of a set.
Write java code to Demonstrates the use of a map to manage a set of objects.
Develop a class ResizingArrayQueueOfStrings that implements the queueabstraction with a fixed-size array, and then extend your implementation to use arrayresizing to remove the size restriction.Develop a class ResizingArrayQueueOfStrings that implements the queueabstraction with a fixed-size array, and then extend your implementation to use arrayresizing to remove the size restriction.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning