Question
my code: #include #include #include #include using namespace std; //function Prototype char *Capitalizer(char *); char again; int main() { char *newline,line[1001]; //That's A Big Buffer,
my code: #include
//function Prototype char *Capitalizer(char *); char again;
int main() { char *newline,line[1001]; //That's A Big Buffer, It Might Be TOO Big... Careful There...
cout << "This program will capitalize the first letter of each sentence. ";
cout << "Please enter a phrase of no more than 1000 characters, followed by a period. "; cin.getline(line, 1001); newline = Capitalizer(line); cout << " This is how you should have done it: ";
cout << newline; cout << endl; getch(); return 0; }
char *Capitalizer(char *sentencePrt) { int i = 0, j; do { cout << "Would you like to play again? (y/n):"; cin >> again; } while (again == 'y'); if(sentencePrt[i] > 97 && sentencePrt[i] < 112) { sentencePrt[i] -= 32; }
for(i = 0; i < strlen(sentencePrt); i++) { j = i;
if(sentencePrt[i] == '.' || sentencePrt[i] == '?' || sentencePrt[i] == '!' || sentencePrt[i] == ',') { j++;
if(sentencePrt[j] == ' ' || sentencePrt == NULL || sentencePrt == 0) { j++;
} if((sentencePrt[j] > 97 && sentencePrt[j] < 112)) { sentencePrt[j] -= 32; }
} }
//cout << sentencePrt; return sentencePrt; }
I keep getting the do while before it even show the output for the code above: I want to input the do while loop using this:
do {
cout << "Would you like to play again? (y/n):";
cin >> again;
}
while (again == 'y')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started