So I am new to C++ and tried to create a function that would remove vowels from a string, but I am failing at it horribly, Here is my code so far :
#include <string>
using namespace std;
string remove(string st) {
for(int i = 0; st[i] != '\0'; i++)
st[i] = st[i] == 'a' || st[i] == 'e' || st[i] == 'i' || st[i] == 'o' || st[i] ==
'u' || st[i] == 'A' || st[i] == 'E' || st[i] == 'I' || st[i] == 'O' || st[i] ==
'U' ? '' : st[i];
}
return st;
This seems to throw an error ? any idea what I am doing wrong
The error I get is :
main.cpp:10:16: error: expected expression 'U' ? '' : Z[i];
And running on another interpreter :
.code.tio.cpp:7:14: error: incompatible operand types ('const char *' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' (aka 'char'))
'U' ? "" : Z[i];
^ ~~ ~~~~