Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (anonymous):

Write a program that inputs a line of text and a substring to search for.Then it should display the position of first and last occurence of the word?

OpenStudy (e.mccormick):

OK. What language, how far did you get, and where are you having trouble?

OpenStudy (e.mccormick):

What you need to use is not that hard to describe. Most programming languages have a string search that takes a string, a sub-string, and a starting point as arguments. They return the numerical position in the string of the next instance of the sub-string after the starting point. That, a little bit of input and output, a loop, and a conditional statement should cover it. Well, you might need the length of the string function and some little things like that, but still, not much else.

OpenStudy (anonymous):

Sorry its C++

OpenStudy (e.mccormick):

http://www.cplusplus.com/reference/string/string/find/

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!