Hexadecimal Problem

bbtss
bbtss used Ask the Experts™
on
char *pMsgString[12] = {"\x0b HDLC defines three.... ",
                   "\x0b esponse Mode (NRM)..., ",
                   "\x0b RM), and Asynchronous...",
                   "\x0b Normal Response Mode...",
                   "\x0b guration. The Primary... ",
                   "\x0b \x1aommunication on the.... ",
                   "\x0b permitted to transmit... ",
                   "\x0b have been requested to...",
                   "\x0b a pool). It is a Maste...",
                   "\x0b Asynchronous Balanced... ",
                   "\x0b buggests is a balance...",
                   "\x0b e either station ca....."
                   };

This is the string I am going to transmit over to another computer using a communication card. I am suppose to make it look like it is on HDLC protocol. So I have to add a control field and address field in front of it which is in hexadecimal. I try using ascii code but I can't manage to get a hexdecimal 00 symbol. Hopefully sombody can help me with this problem.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
fputc(0,file);

Commented:
A C string is terminated by a hex zero, thus it cannot have embedded zeros in it.

You would have to use some other markers and explicitly transmit zero characters when you reach them.
Commented:
You cannot use CStrings for characters containing zeros as a zero represents the terminating character, but you can include Character Constants see

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang98/html/_pluslang_c.2b2b_.character_constants.asp

For example:
CString sMyString = "My first carriage return \r"
The \r will instruct the compiler to add the hex equivalent 0x0d at the end.

To use zeros choose char* pMyArray[n] but remember that your Watch window thinks it should obey the rules of char strings ie a zero means end on the string and your char* pMyArray will only be displayed up until the first zero!

To see the rest of your string use the memory window and look at the address of pMyArray.

Hope this is of some use!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial