Question: Given the following program, i get this error. How do i fix my code?Here is the error that shows up : Program generated too much

Given the following program, i get this error. How do i fix my code?Here is the error that shows up :
Program generated too much output. Output restricted to 50000 characters. Check program for any unterminated loops generating output.
This is the code used for the program:
#include #include #include #include using namespace std; int main(){ string title, col1Header, col2Header; vector dataStrings; vector dataIntegers; cout "Enter a title for the data: "; getline(cin, title); cout "You entered: " title endl; cout "Enter the column 1 header: "; getline(cin, col1Header); cout "You entered: " col1Header endl; cout "Enter the column 2 header: "; getline(cin, col2Header); cout "You entered: " col2Header endl; while (true){ cout "Enter a data point (-1 to stop input): "; string input; getline(cin, input); if (input =="-1"){ break; } size_t commaPos = input.find(","); if (commaPos == string::npos){ cout "Error: No comma in string." endl; continue; } size_t secondCommaPos = input.find(",", commaPos +1); if (secondCommaPos != string::npos){ cout "Error: Too many commas in input." endl; continue; } string dataString = input.substr(0, commaPos); string dataIntegerStr = input.substr(commaPos +2); try { int dataInteger = stoi(dataIntegerStr); dataStrings.push_back(dataString); dataIntegers.push_back(dataInteger); cout "Data string: " dataString endl; cout "Data integer: " dataInteger endl; } catch (const invalid_argument&){ cout "Error: Comma not followed by an integer." endl; continue; }} cout setw(33) right title endl; cout setw(20) col1Header setw(23) col2Header endl; for (size_t i =0; i dataStrings.size(); i++){ cout setw(20) right dataStrings[i] setw(23) dataIntegers[i] endl; } cout "Histogram:" endl; for (size_t i =0; i dataStrings.size(); i++){ cout setw(20) right dataStrings[i]""; for (int j =0; j dataIntegers[i]; j++){ cout "*"; } cout endl; } return 0; }
Given the following program, i get this error.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!