How to check if substring exists in a string in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>
 
int main() {
    char s[] = "c c++ java python c#";  
      
    if (strstr(s, "java")) {
        puts("Exists");
    }
    else {
        puts("Not exists");
    }
  
    return 0;
}
          
         
         
 
/*
run:
 
Exists
 
*/

 



answered Apr 8, 2021 by avibootz

Related questions

1 answer 179 views
1 answer 165 views
1 answer 140 views
1 answer 251 views
1 answer 197 views
...