I managed to solve my problem, it working properly and giving the correct results. The problem now is that I have this warning: Implicit conversion from char* to bool[readability-implicit-bool-conversion].
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
bool is_letter(const char s) {
return ('a' <= s && s <= 'z') || ('A' <= s && s <= 'Z');
}
int main() {
const int MAX_LENGTH = 260;
const int VOWELS = 11;
char is_vowel[VOWELS] = "aeiouAEIOU", s[MAX_LENGTH];
ifstream fin("date.in");
int k;
cin >> k;
int start = -1,nrVowels = 0, finish = 0, counter = 0;
while (!fin.eof()) {
fin.getline(s, MAX_LENGTH);
int n = strlen(s);
int have_word = 0;
for (int i = 0; i < n; ++i) {
if (is_letter(s[i])) {
have_word = 1;
if (strchr(is_vowel, s[i])) {
++nrVowels;
}
if (counter == 0) {
start = i;
finish = i;
++counter;
} else {
finish = i;
}
} else if (have_word == 1) {
if (nrVowels >= k) {
for (int i = start; i <= finish; ++i) {
cout << s[i];
}
cout << "\n";
}
counter = 0;
have_word = 0;
nrVowels = 0;
}
}
if (have_word == 1) {
if (nrVowels >= k) {
for (int i = start; i <= finish; ++i) {
cout << s[i];
}
cout << "\n";
}
counter = 0;
nrVowels = 0;
finish = 0;
}
}
return 0;
}
The error appears on the line where I am searching for the vowels "
if (strchr(is_vowel, s[i]))
"