Question: I'm geeting a compilation error that says Program generated too much output. Output restricted to 50000 characters. Check program for any unterminated loops generating output.

I'm geeting a compilation error that says "Program generated too much output. Output restricted to 50000 characters. Check program for any unterminated loops generating output." I do not know how to fix that

#include #include using namespace std;

int main() {

string userSentence; // Input string string phraseToFind; char menuOption; char printMenu(); int GetNumOfNonWSCharacters(string); int GetNumOfWords(string); void ReplaceExclamation(string&); void ShortenSpace(string&); int FindText(string, string);

cout << "Enter a sample text:" << endl << endl; getline(cin, userSentence); // Print string cout << "You entered: " << userSentence << endl; while(1) { // Print Menu menuOption = printMenu(); // Call the needed function switch(menuOption) { case'C': case'c': cout << "Number of non-whitespace characters: " << GetNumOfNonWSCharacters(userSentence) << endl; break; case'W': case'w': cout << "Number of words: " << GetNumOfWords(userSentence) << endl; break; case'F': case'f': cout << "Enter a word or a phrase to find: "; getline(cin, phraseToFind); cout << phraseToFind << FindText(userSentence, phraseToFind); break; case'R': case'r': ReplaceExclamation(userSentence); cout << "Edited Text: " << userSentence<< endl; break; case's': case'S': ShortenSpace(userSentence); cout << "Edited Text: " << userSentence << endl; case'q': case'Q': return 0; default: cout << "Wrong choice.. enter a new one letter" ; break; } } return 0; } char printMenu() { char letter; // Display Menu cout << endl << "MENU" << endl; cout << "c - Number of non-whitespace characters" << endl; cout << "w - Number of words" << endl; cout << "f - Find text" << endl; cout << "r - Replace all !'s" << endl; cout << "s - Shorten spaces" << endl; cout << "q - Quit" << endl; // ask for input and display it cout << endl << "Choose an option:" << endl; cin >> letter; return letter; } int GetNumOfNonWSCharacters(const string userSentence) { int i; int count; int length = userSentence.size(); for (i=0; i< length ; i++) { if(!isspace(userSentence[i])) count++; } return count; } int GetNumOfWords(const string userSentence) { int wordCount = 0; int i; int length = userSentence.size(); for (i=0; i < length;) { if(isspace(userSentence[i])) { while(isspace(userSentence[i])) i++; wordCount++; } else { i++; } } wordCount = wordCount + 1; return wordCount; }

void ReplaceExclamation(string& userSentence) { string replacedText = userSentence; int i; int length = userSentence.size();

for(i=0; i< length ; i++) {

if(userSentence[i] == '!') replacedText[i] = '.'; } userSentence = replacedText; }

void ShortenSpace(string& userSentence) { char *replacedText; int i; int j=0; int length = userSentence.size(); replacedText = new char[length+1];

for(i=0; i

replacedText[j] = userSentence[i];

if(isspace(userSentence[i])) { while(isspace(userSentence[i])) i++; } else { i++; } } replacedText[j] = '\0'; userSentence = replacedText; }

int FindText(string userSentence, string phrase) { int count = 0;

if (phrase.size() == 0) return 0;

for(size_t offset = userSentence.find(phrase); offset != string::npos; offset = userSentence.find(phrase, offset + phrase.size())) { ++count; } return count; }

/* Type your code here. */

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 Databases Questions!