C programming language" /> Manipulating binary strings
Home

 

Manipulating binary strings

Declare strings of binary data as one of the MQBYTEn data types. Whenever you copy, compare, or set fields of this type, use the C functions memcpy, memcmp, or memset; for example:

#include <string.h>
#include "cmqc.h"
 
MQMD MyMsgDesc;
 
memcpy(MyMsgDesc.MsgId,           /* set "MsgId" field to nulls    */
       MQMI_NONE,                 /* ...using named constant       */
       sizeof(MyMsgDesc.MsgId));
 
memset(MyMsgDesc.CorrelId,        /* set "CorrelId" field to nulls */
       0x00,                      /* ...using a different method   */
       sizeof(MQBYTE24));

Do not use the string functions strcpy, strcmp, strncpy, or strncmp, because these do not work correctly for data declared with the MQBYTEn data types.



 

Home