0

Why does my code give a weird o/p in this following condition?

https://code.sololearn.com/cmkYH9Hm4cmY/?ref=app Here if I give eg: string1 : Tiger string2 : Lion char1 for string1 : a char2 for string2 : n It gives "Char1 not found in string1" but gives some weird number for char2 only on this condition where char1 is not present in string1 And char2 is present in the last index of string2. Why does this happen?

21st Jul 2021, 4:50 PM
Srinath
3 odpowiedzi
+ 1
you are using same p and a after testing for q!=NULL check if u really want p-a+1 in both printf statements. i dont think you do.
21st Jul 2021, 5:15 PM
arturop200
arturop200 - avatar
+ 1
NotAPythonNinja oh thanks, didn't notice that. Now I get it correctly 👍
22nd Jul 2021, 12:31 PM
Srinath
+ 1
Arturop that was a big typo, I didn't notice it. Thanks for pointing it out.
22nd Jul 2021, 12:32 PM
Srinath