Inserting a character in a string in c++ -
Inserting a character in a string in c++ -
my task is:::: delete vowels, insert character "." after each consonant.
so programme made inserts "." @ begining ......... help me
http://ideone.com/y8doxt
#include <iostream> #include <string> using namespace std; bool isvowel(char ch); int main() { string orwr; int j = 0; getline(cin, orwr); (j=0; j<6; j++) { if(isvowel(orwr[j])==1) {orwr.erase(j, 1);j--;} else {orwr.insert(j, 1, '.');j++;} } cout<<orwr; homecoming 0; } bool isvowel(char ch) { switch(ch) {case 'a': case 'a': case 'e': case 'e': case 'i': case 'i': case 'o': case 'o': case 'u': case 'u': homecoming true; default: homecoming false;}}
your loop shoul :
(j=0; j<orwr.length(); j++)
and not:
(j=0; j<6; j++)
c++ string insert character
Comments
Post a Comment