post  type word

ripley (51)   Link to this post
hello,

i am very new to c++. and i am having problem like this:

i definied a new type

typedef unsigned short int word

word k[5] = {0xaaaa, 0xbbbb, 0xaccc, 0x0101, 0x3333};
for(int i=0; i<5; i++)
cout << (k[i]) <<"\n";

and i want to print it in hexa format, as it was on input. can anybody tell me how to do it with the easiest way? thank you.

r
Bazzy (4120)   Link to this post
cout << hex << k[i];
http://www.cplusplus.com/reference/iostream/manipulators/hex/
ripley (51)   Link to this post
thank you :)

This topic is archived - New replies not allowed.