How to check if a string contain two other strings in C

1 Answer

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

int main() {
	char a[] = "abcd";
	char b[] = "xyz";
	char c[] = "abcdxyz";

	if (strstr(c, a) && strstr(c, b)) 
        puts("yes");
    else
        puts("no");
	
    return 0;
}

 
 
/*
run:
 
yes

*/

 



answered Oct 20, 2019 by avibootz

Related questions

1 answer 142 views
2 answers 237 views
1 answer 117 views
1 answer 207 views
...