+ 2
Hex color
Does anyone know how to check if a string is a valid hex color representation? I could find the codes is JS and other languages but i want it in c++ or c .
1 ответ
+ 2
Hi🙋Maryam ...
For ex::
int check_hex(char str[]){
int i=0;
char ch=str[i];
while(ch!='\0'){
if(!(isxdigit(ch))
return 0;
i++;
ch=str[i];
}
return 1;
}
"isxdigit" function in C checkes that whether the given character is hexadecimal or not. And it's defined in ctype.h header file👌..