-1

Is there a function to search a string inside of string? For example: String: "Hello". And I want to check if the string "ell" is inside the string "Hello".

Saga
  • 67
  • 1
  • 8

2 Answers2

0

What about strstr()?

char *strstr(const char *haystack, const char *needle);

for your example, just do the following:

char *ocurrence_str = strstr("Hello", "ell");
JFMR
  • 23,265
  • 4
  • 52
  • 76
0

Use library strstr() function, which is returns pointer to the first occurrence of the string in a given string.

Read man page of strstr function for more information.

msc
  • 33,420
  • 29
  • 119
  • 214