So I am writing this program that takes in two strings from console and then switches the vowels in string1 for the vowels in string two in order of ocurrance. For example:
text 1 = rapid
text 2 = ouch
result string = ropud
this is what i have so far:
but I think there has got to be a better way of doing this. As of now, I am not sure what my next step should be or if the program is ok. Can anyone suggest anything or point out something I did wrong?Code:#include "stdafx.h" #include <iostream> #include <string> #include <cstring> using namespace std; bool isVowel (char); void main() { string text1, text2, translation; cin >> text1; cin >> text2; cout << "You entered: " << text1 << endl; cout << "You entered: " << text2 << endl; string result; int i1 = 0; int i2 = 0; //while ( i1 < s1Length() && i < s2Length()) while ( i1 < text1.length() || i1 < text2.length()) { for (;i1 < text1.length() && isVowel(text1[i1]) ; i1++) { if(i1 < text1.length()) result += text1[i1]; } cout << result; } } bool isVowel (char c) { const string vowels = "aeiouAEIOU"; for (int i = 0; i < vowels.length(); i++) if (c == vowels[i]){ return true;} return false; }