How to check if char exist in a string with C

1 Answer

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

int main()
{
    char str[] = "C Programming";

    if (strchr(str, 'P') != NULL) {
        puts("exist");
    }
    else {
        puts("not exist");
    }
}




/*
run:

exist

*/

 



answered Sep 27, 2022 by avibootz

Related questions

1 answer 151 views
1 answer 122 views
1 answer 131 views
1 answer 193 views
1 answer 141 views
...