Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to compare 2 hex string values

Status
Not open for further replies.

Lorey

Programmer
Feb 16, 2003
88
SG
hi experts!

i have 2 vectors of type unsigned char. with hex values in it. I want to compare the two if the same. Does anybody knows how to do it ?

Thanks in advance
lorey
 
No, that compares the string pointers.

If you're sure the hex values both start (or don't start) with 0x and have the same number of hex digits, you can compare them with strcmp.

If you're not sure, convert both to integers to atol(), then use ==.
 
She didn't say anything about pointers, so I'm assuming she's just storing numbers between 0-255 as unsigned chars. In that case, using == is all you need. If it's a char string, then convert them both to lower-case (or upper-case) and use strcmp().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top