Sure I don't expect you to do all my work...
So far, I only got this far. And the output is just some unreadable characters.
Code:
int saveMessage(MQMD *md)
{
char fileName[1024];
unsigned char *pch;
int i;
pch = (unsigned char *)malloc(sizeof(md->MsgId));
memcpy(pch, md->MsgId, sizeof(md->MsgId));
for (i = 0; i < sizeof(md->MsgId); i++)
{
pch[i] = (md->MsgId[i] & 0x0f);
}
for (i = 0; i < sizeof(md->MsgId); i++)
{
printf("%c", (char)pch[i]);
}
pch[++i] = '\0';
printf("pch: %s\n", pch);
// and here i would like to memcpy pch somewhere, build a complete path+filename and then work with the file as usual
free(pch);
}
The next piece of code is what I took from an example that prints the MsgID in the way I need it, except it prints it to an output and not to a variable (what is what I need):
Code:
for(i=0;i<24;i++) printf("%1.1X",(md->MsgId[i] & 0x0f) );