How To Check If Char In String C

[Solved] How To Check If Char In String C | Basic - Code Explorer | yomemimo.com
Question : check if string contains a character in c

Answered by : oskari-lehtinen

#include <stdio.h>
#include <string.h>
int main(void)
{ char str[] = "Hi, I'm odd!"; int exclamationCheck = 0; if(strchr(str, '!') != NULL) { exclamationCheck = 1; } printf("exclamationCheck = %d\n", exclamationCheck); return 0;
}

Source : https://stackoverflow.com/questions/58146750/how-do-i-check-if-a-string-contains-a-certain-character | Last Update : Wed, 04 May 22

Question : c check if char is an operator

Answered by : huldar

char o = '+';	//Or some other character
if (o == '%' || o == '/' || o == '*' || o == '+' || o == '-') {	//Do something //...
}

Source : https://stackoverflow.com/questions/52611127/check-if-an-character-is-an-operator/52611158 | Last Update : Tue, 16 Jun 20

Answers related to how to check if char in string c

Code Explorer Popular Question For Basic