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
Get step-by-step solutions from verified subject matter experts
