I wrote a very basic program to separate vowels from a input string. The program is separating vowels but also returning weird symbols/letters!
I seriously can't find why it is happening! help!
output >>
aoeeo x ╘E⌡óì
It generates different letters(?) everytime i run it!
code >>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
string input = "stackoverflow";
vector<char> vowels = {'a','e','i','o','u'};
vector<char> result;
for(int i = 0 ; i < input.size() ; i++){
for(int j = 0; j < vowels.size(); j++){
if(input[i] == vowels[j]){
result.push_back(input[i]);
}
}
if (input[i] == 'u' || input[i] == 'e') {
result.push_back(input[i]);
}
}
for(int i = 0 ; i < input.size() ; i++){
cout << result[i];
}
return 0 ;
}
Aucun commentaire:
Enregistrer un commentaire