Find subString in String

Hi All,
I have written the below program to find the substring in the string. in case one word coming multiple time how to handle this situation ? the below program retuning -1 as position which is wrong.
Code
  1. Input ("abhijit" , "jit"//int position = -1;
Copyright GeekInterview.com

How to fixi it ?

Questions by yrs_abhishek

Showing Answers 1 - 3 of 3 Answers

Kanwarjeet Yadav

  • Aug 7th, 2013
 

Find Substring in string

Code
  1.  

  Was this answer useful?  Yes

Danthe74

  • Dec 14th, 2014
 

My solution require only one while loop.
Function returns the position of find chars.

Code
  1. span style="font-style: italic;">// Marker for Position// Loop charSuper// Loop charSub// Count number of find chars in charSuper// charSuper is less longer than charSub

  Was this answer useful?  Yes

Annon

  • Jun 15th, 2016
 

This answer is wrong. Ex:
substr("abcabcabcd", "abcabcd")
=> false (should return true)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions