Program from C++ text book

  • #1

Main Question or Discussion Point

I was reading my text book to study for a test in my C++ class and I cam across this question and the answer is not in the book. I'm afraid I might need to know how to do something like this for my test and there isn't an example of one like it in my book. I'm not sure how to do it so I don't have any code to show you guys. I was wondering if anyone knew the answer to this question. Thanks!

Here it is:

Substring function

Write a program that finds a substring inside a string. Main program asks users to type a string and then a substring. Then, program calls a subfunction int mystrstr(char *str, char *substr). Inside the mystrstr subroutine, program searches substring substr in the string str and returns the starting position of the substring in the string. If the substring is not located in the string, then subroutine return -1. After searching the position, main program prints out the string from the position to the end of string of the string. e.g. string: "C++ program is really fun", substring: "program", Then, your program will print "program is really fun"
 

Answers and Replies

  • #2
33,179
4,859
What have you tried?
 

Related Threads for: Program from C++ text book

  • Last Post
Replies
1
Views
2K
Replies
6
Views
815
  • Last Post
Replies
13
Views
1K
  • Last Post
Replies
14
Views
1K
Replies
1
Views
2K
Replies
17
Views
4K
Top