-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
  • 7

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");
ネロク
  • 21,268
  • 3
  • 51
  • 67
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
  • 32,079
  • 22
  • 110
  • 197