+ 1
Hello everybody. How to write a code?
My question: string str("one hundred and six"); I want to check if sting str contains substring "and". If it is true then erase it and use str otherwise use original string str. Shortly I want to get rid of "and" substr if str has it.
13 Answers
+ 1
If there is no "and" in the string, you don't change the string ā no need for a "else", right?
0
Do you remove just one substring? what if there are more than one substring "and"?
0
bool found = 0;
string a("two hundred and six");
//bool found;
int d1 = a.length();
if(found)
a = a.erase(a.find("and"), 4);
}
else{????}
Yes, I did this but I don't know what goes into else statement
0
Yes, you can have "and" or not. If yes then it must be removed, else goes on.
- 1
No there is only one.
- 1
l
P
- 1
Hi
- 1
Just do it šššš
- 1
Hello