G
galapogos
Hi,
I'm trying to compare an array of unsigned chars(basically just data
without any context) with a constant, and I'm not sure how to do that.
Say my array is array[10] and I want to compare it with the constant
0x00010203040506070809 where array[0] == 0x00, array[1] == 0x01, etc.
How do I do that. Obviously I can't use memcmp() with the
0x00010203040506070809 since the compiler will use that constant as an
address and give me a segfault. Other than doing an if (array =
0x0i) for all 10 values of i, how can I do such a compare? I thought of
converting the constant to a string and doing a memcmp/strcmp using
that string but not all the bytes are printable ASCII characters.
Thanks!
I'm trying to compare an array of unsigned chars(basically just data
without any context) with a constant, and I'm not sure how to do that.
Say my array is array[10] and I want to compare it with the constant
0x00010203040506070809 where array[0] == 0x00, array[1] == 0x01, etc.
How do I do that. Obviously I can't use memcmp() with the
0x00010203040506070809 since the compiler will use that constant as an
address and give me a segfault. Other than doing an if (array =
0x0i) for all 10 values of i, how can I do such a compare? I thought of
converting the constant to a string and doing a memcmp/strcmp using
that string but not all the bytes are printable ASCII characters.
Thanks!