get_nth_comma_in_string(s, n): This function takes a string s and a non-negative integer n as input. It returns the index of the n’th comma in the string s. We will start counting at 0, so if n=0, then the index of the first comma should be returned; if n=1, then the index of the second comma should be returned, and so on. If there is no n’th comma in s, then -1 should be returned. Note: You may use the string find method in this function.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 8PE: Write a program that reads in a line consisting of a students name, Social Security number, user ID,...
icon
Related questions
Question

get_nth_comma_in_string(s, n): This function takes a string s and a non-negative integer n as input. It returns the index of the n’th comma in the string s. We will start counting at 0, so if n=0, then the index of the first comma should be returned; if n=1, then the index of the second comma should be returned, and so on. If there is no n’th comma in s, then -1 should be returned. Note: You may use the string find method in this function.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning