Reputation: 631
When I give an input of uppercase preceeded by a vowel ,it is not converting the uppercase letter into lowercase e-g-Input-aBAcAba output-.B.c.b
int main()
{
int i;
locale loc;
string a;
cin>>a;
for(i=0;i<a.size();i++)
{
if(isupper(a[i]))
a[i]=tolower(a[i]);
if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')
{
a.erase(a.begin()+i);
}
if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')
i--;
}
for(i=0;i<a.size();i++)
cout<<'.'<<a[i];
return 0;
}
Upvotes: 1
Views: 48
Reputation: 92301
if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')
i--;
This doesn't work, because you have already erased the vowel from a
, so the decrement doesn't happen and you skip the next character.
You might instead want to do
if (condition)
a.erase(...);
else
++i;
and remove the increment from the for-statement.
Upvotes: 2