C strstr()

The strstr() function returns pointer to the first occurrence of the matched string in the given string. It is used to return substring from first match till the last character.

Syntax:

snippet
char *strstr(const char *string, const char *match)

String strstr() parameters

string: It represents the full string from where substring will be searched.

match: It represents the substring to be searched in the full string.

String strstr() example

snippet
#include
#include   
int main(){  
  char str[100]="this is rookienerd with c and java";  
  char *sub;  
  sub=strstr(str,"java");  
  printf("\nSubstring is: %s",sub);  
 return 0;  
}

Output:

Output
rookienerd with c and java
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +