I’m trying to create a function that will replace 0’s, 1’s, or 2’s with spaces in a string. I’m going about it by iterating through the string and comparing each individual character.
My function will work if I compare str_in[i] == ‘0’, but if I add the or statement it returns nothing.
Snippet:
string omit_num( string ) {
int i ;
str_len = str_in.length();
str_out = "" ;
for( i = 0 ; i < str_len ; i ++ ){
cout << str_in[i] << endl;
if ( str_in[i] == '0' || '1' || '2')
app = " " ;
else
app = str_in[i];
str_out.append(app) ;
}
return str_out;
}
You need