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".
            Asked
            
        
        
            Active
            
        
            Viewed 134 times
        
    -1
            
            
        - 
                    2[`strstr`](http://en.cppreference.com/w/c/string/byte/strstr) – WhozCraig May 18 '17 at 16:51
- 
                    1try [`strstr()`](https://linux.die.net/man/3/strstr) – May 18 '17 at 16:51
- 
                    2A [good standard string function reference](http://en.cppreference.com/w/c/string/byte) should help. – Some programmer dude May 18 '17 at 16:52
- 
                    1Ah.. I am probably too late with all ya guys to suggest `strstr`? – Paul Ogilvie May 18 '17 at 16:53
- 
                    duplicate: https://stackoverflow.com/questions/26231388/checking-if-string-contains-substring-in-c – WhozCraig May 18 '17 at 16:53
2 Answers
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
- 
                    1Note: C has no builtin functions! The standard library is not builtin. – too honest for this site May 18 '17 at 17:01
