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

1 Answer

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

int main(int argc, char **argv) 
{
    char s[] = "c programming language"; 
	
	if (strchr(s, 'g'))
		printf("Exist\n");
	else
		printf("Not exist\n");
	
	return 0;
}
 
   
/*
run:
 
Exist
 
*/

 



answered Feb 3, 2019 by avibootz
...