How to check if a substring exists in a string with C

1 Answer

0 votes
#include <stdio.h> 
#include <string.h> 

int main(void)
{   
    char s[30] = "c c++ c# java", search[10] = "java";
    
    if (strstr(s, search)) 
        printf("exists\n");
    else
        printf("not exists\n");
     
    return 0;
}
  
        
/*
run:
     
exists

*/

 



answered Mar 27, 2017 by avibootz

Related questions

1 answer 204 views
1 answer 160 views
1 answer 135 views
1 answer 244 views
1 answer 192 views
...