Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a section of my code where I've narrowed down my problem is. The code keeps truncating the first letter of the inputs from

This is a section of my code where I've narrowed down my problem is. The code keeps truncating the first letter of the inputs from the user after the first response.

im assuming that my problem is with my getline statement or my ignore statement?

string generateMadLib(vector& madLibs, vector& labels) { for (int i = 0; i < madLibs.size(); i++) { string madLib = madLibs[i]; int pos = madLib.find("REPLACE"); while (pos != string::npos) { string label = labels[i]; string article = getArticle(label); cout << "Enter " << article << " " << label << ": "; string userInput; cin.ignore(); // Clear the newline character left in the buffer getline(cin, userInput); madLib = madLib.replace(pos, 7, userInput); pos = madLib.find("REPLACE"); i++; } return madLib;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entrepreneurship

Authors: Andrew Zacharakis, William D Bygrave

5th Edition

1119563097, 9781119563099

More Books

Students also viewed these Databases questions

Question

What is the role of cognition and thought in learning?

Answered: 1 week ago

Question

What are bounds and what do companies do with them?

Answered: 1 week ago