Link to home
Start Free TrialLog in
Avatar of airek
airek

asked on

Binary data with MSComm control in VC++

I need to recieve binary data with an MSComm communications control in VC++ 6.0 with MFC. I know that in VB you can set the InputMode property to binary but I can't find any way to do this in C. The problem is that my data contains bytes with the value zero and input is a string so a zero byte terminates the string.
ASKER CERTIFIED SOLUTION
Avatar of NickRepin
NickRepin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NickRepin
NickRepin

C strings can contain zeroes inside. But to work with such string, you have to know its length.

Then you can, for example, print the string contents as hex data:

for(i=0;i<nStringLength;i++)
 printf("%02X, ",(int) String[i]);

But you cannot use such string in

  printf("%s",String)

because only initial part of the string, terminated by zero, will be printed.