I have a long string "given_string", and I'm trying to find hex values within that string. Here's a simplified example:
/* Find a sub-string in a given string: */
char * given_string = "This is a long given string. 0xff. Happy Programming! ";
int length = strlen(given_string);
for (int i = 0; i < length; i++)
{
if(given_string[i] == 0xff)
{
printf("%c\n", given_string[i]);
}
}
Though when I run the above code, I get this error:
warning: comparison of constant 255 with expression of type 'char' is always false
[-Wtautological-constant-out-of-range-compare]
if(given_string[i] == 0xff)
~~~~~~~~~~~~~~~ ^ ~~~~
1 warning generated.
How do I find hex values in a string?