0

I was wondering if there is any way to check if a string is included in a string. For example if I have the string1: superman and string2: per I would like to know that string2 is contained in string1 and that the first letter of string2 is in position 2 of the string array of string1. Is it possible to do some trick with some already built function to achieve this?

Hassan Hosseini
  • 410
  • 1
  • 4
  • 20
awwww
  • 23
  • 5
  • 1
    Does this answer your question? [Check substring exists in a string in C](https://stackoverflow.com/questions/12784766/check-substring-exists-in-a-string-in-c) – Brian61354270 Feb 15 '20 at 20:42
  • Do you know what it will do if the substring is repeated 2 times in the original string? – awwww Feb 15 '20 at 20:59

1 Answers1

0

You may use strcmp function. The strcmp() function compares two strings and returns 0 if both strings are identical. Find more information from the following link. https://www.programiz.com/c-programming/library-function/string.h/strcmp

  • yes I knew about it but is not what I'm searching for, cause it doesn't see if a word is contained into another, see the example right up – awwww Feb 15 '20 at 20:54