+ 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.

22nd Oct 2021, 2:46 PM
TeaserCode
9 Antworten
+ 1
If there is no "and" in the string, you don't change the string – no need for a "else", right?
22nd Oct 2021, 5:40 PM
Lisa
Lisa - avatar
0
Do you remove just one substring? what if there are more than one substring "and"?
22nd Oct 2021, 3:13 PM
Ipang
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
22nd Oct 2021, 4:37 PM
TeaserCode
0
Yes, you can have "and" or not. If yes then it must be removed, else goes on.
22nd Oct 2021, 5:47 PM
TeaserCode
- 1
No there is only one.
22nd Oct 2021, 3:19 PM
TeaserCode
- 1
l P
24th Oct 2021, 5:41 AM
Nwenyim Andrew
Nwenyim Andrew - avatar
- 1
Hi
24th Oct 2021, 7:21 AM
Satya Midatana
Satya Midatana - avatar
- 1
Just do it 😁😁😁😁
24th Oct 2021, 11:03 AM
Bramanta Wisnu
- 1
Hello
24th Oct 2021, 2:28 PM
سید محمد حسینی