Whale_talk

#include<iostream>

#include<vector>

#include<string>

int main() {

  std::string input = "turpentine and turtles";

  std::vector<char> vowels = {'a','e','i','o','u'};

  std::vector<char> result;

  for(int i = 0;i < input.size();i++) {

    for(int j = 0;j < vowels.size(); i++) {

      

      if(input[i] == vowels[j]) {

      result.push_back(input[i]);

      } 

      if( input[i] == 'u' || input[i] == 'e') {

        result.push_back(input[i]);

      }

      

    }

  }

  for(int k = 0; k < result.size();k++) {

    std::cout << result[k];

  }

  std::cout << "n";

}

there is error coming after execution “Segmentation fault (core dumped)” anybody help.

Hello :slight_smile:

This error might indicate that there might be an infinite loop in your code. So take a look at each declaration and you should notice that something is wrong:

for(int i = 0;i < input.size();i++) {
for(int j = 0;j < vowels.size(); i++) {
for(int k = 0; k < result.size();k++) {
2 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.