Reputation: 1
I have some problem with the switch-statement and I don't know how to resolve it:
string phrase;
cout << "enter a phrase:\n";
getline(cin, phrase);
for (unsigned int i = 0; i < phrase.length(); i++)
{
switch (phrase[i])
{
case '-----':
cout << "0";
break;
}
}
It gives me an error that says "too many characters int the char constant". Can somebody tell me how to resolve it? Thanks in advance.
Upvotes: 0
Views: 243
Reputation: 376
string phrase;
int sum=0;
cout << "enter a phrase:\n";
getline(cin, phrase);
for (unsigned int i = 0; i < phrase.length(); i++)
{
switch (phrase[i])
{
case '-':sum+=1;
if (sum%5==0)
cout << "0";
break;
}
}
Upvotes: 1