Question: hello below is my code to output the character number given with user input in a string. i am not sure how to produce the

hello below is my code to output the character number given with user input in a string. i am not sure how to produce the number output after given the string name. I receive an error on line 12 (for)

my example is provided below:

#include

#include

using namespace std;

int main() {

string userText;

int count = 0;

string str;

getline(cin, userText);

cout << "" << endl; // Gets entire line, including spaces.

ERROR OCCURS HERE.....for (int i = 0; i <= userText.length(); i++)

if ((str[i]!=32)&&(str[i]!=44)&&(str[i]!=46)) {

}

++count;

cout << "" << count;

return 0;

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!