Bartleby Related Questions Icon
Related questions
Question
Question 1: break phrase
Problem statement
Breaking a string into two parts based on a delimiter has applications. For example, given an email address, breaking it based on the delimiter "@" gives you the two parts, the mail server's domain name and email username. Another example would be separating a phone number into the area code and the rest.
Given a phrase of string and a delimiter string (shorter than the phrase but may be longer than length 1), write a C++ function named break_string to break the phrase into two parts and return the parts as a C++ std::pair object (left part goes to the "first" and right part goes to the "second").
Transcribed Image Text:Test
#
1
2
3
4
input
phrase =
msmith@gmail.com du";
delemeter = "@";
phrase = "408-345-0000";
delemeter = "-":
"
Output (Need
to print 2 parts
of the std::pair
phrase = "Teachers open the
door, but you must enter by
yourself - Chinese Proverb";
delemeter = "_"
object)
The first part:
msmith
The second
part:
gmail.com
The first part:
408
The second
part: 345-0000
The first part:
An investment
in knowledge
pays the best
phrase = "An investment in
knowledge pays the best
interest. - Benjamin Franklin"; interest.
delemeter = "-
The second
part: Benjamin
Franklin
The first part:
Teachers open
the door, but
you must enter
by yourself
The second
part: Chinese
Proverb
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
This is a popular solution
bartleby
Trending nowThis is a popular solution!
bartleby
Step by stepSolved in 3 steps with 2 images
Knowledge Booster
Background pattern image
Similar questions
- What characters are used as delimiters when null is passed as an argument to the Split method of a string object?arrow_forwardString.ParseInt(m); will convert the integer value of m to a String True Falsearrow_forward3. Word Counter Write a function that accepts a pointer to a C-string as an argument and returns the number of words contained in the string. For instance, if the string argument is "Four score and seven years ago" the function should return the number 6. Demonstrate the function in a program that asks the user to input a string then passes it to the fune- tion. The number of words in the string should be displayed on the screen. Optional Exercise: Write an overloaded version of this function that accepts a string clás object as its argument.arrow_forward
arrow_back_ios
arrow_forward_ios