I'm reading in a *u_char that should be a bunch of hexidecimal flags and then outputing using cout<<. And low and behold, it wants to give me lots of ascii characters. How do I get the cout<< operator to stop converting to ascii and leave them how they are??.
Actually i got it working with a little of both solutions.
(in a for loop with control i)
cout<<hex<<(int)myvalue
Thanks for both, but now i have a new problem too.
I'm basically looking at packets and want to be able to tell that it is an IP protocol packet, so it should have the hex flag 0x0800 at a certain point. But since i'm working with a *u_char where i look at it as an array myvalue[x]. The question is, is each spot in that array one digit in decimal form? hex form? If anyone knows, that'd be great.
Thanks again, I think i can see where you're coming from. What I did was a little different. I'm not sure how the *u_char is storing them, but when I
cout<<dec<<u_char<<" "
in a for loop so i can see each individual integer stored, i get numbers between 0 and 255 (0xff) which makes sense cause i'm looking at a paket. What i did then was figure out where somewhere in the sequence I continually saw
"..X 8 0 Y....." and that is what i was looking for. So i figured out that was the u_char[12] and u_char[13] and can compare now using
if ( ((int)u_char[12] == 8) && ((int)u_char[13] == 0))
then it has the flag 0x0800. I highly doubt this is anywhere near efficient though, so any better suggestions would be great!!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.