0
My question: How to iterate through string? Code is written bellow.
https://code.sololearn.com/cP08J9biAZ8y/?ref=app I want to get three strings from main string. I get the first two strings. To get the thirth one I suppose to use continue and write all remaining letters to the thirth string, but problem is I do not know how to continue over the first two strings, which are already used.
3 Réponses
+ 1
for(int i1=0; i1<(int)str.length(); i1++)
if( !(str[i1]==',' || str[i1]=='!' || (str[i1]==' ' && i1==0) || (str[i1]==' ' && str3[str3.length()-1] == ' ')) )
str3 += str[i1];
str3[str3.length()-1]='.'; // set last char a dot. instead of \n;
Try this ;
You can use isAplha(), isDigit(), ... Methods of string class for simplifying comparisions...
Hope it helps...
0
What is your expected output?
0
I would like to split orig string into three strings. First string represents name, which is in <> brackets in original string, then phone number which starts with +, and thirth one is address. I have already extracted the first and the second ones, but then there are remaining characters which represent address. Between these characters are also special characters which should not be in the address.
Problem is when I use erase function then in address string appears extra spaces and I don't know how to remove them.