UCHAR to CString
-
Hi i wonder if anybody can answer this (simple?) question, i have a buffer returned from a library call declared as:
const UCHAR* pkt_data
and i want to fill a CString object from a certain postion from that buffer, say 14 charachers in, I have looked at all the CString articles here and for the life of me cannot figure out how to do it. Can anybody be so kind as to post a code snippet? Cheers Andy -
Hi i wonder if anybody can answer this (simple?) question, i have a buffer returned from a library call declared as:
const UCHAR* pkt_data
and i want to fill a CString object from a certain postion from that buffer, say 14 charachers in, I have looked at all the CString articles here and for the life of me cannot figure out how to do it. Can anybody be so kind as to post a code snippet? Cheers Andy -
Hi i wonder if anybody can answer this (simple?) question, i have a buffer returned from a library call declared as:
const UCHAR* pkt_data
and i want to fill a CString object from a certain postion from that buffer, say 14 charachers in, I have looked at all the CString articles here and for the life of me cannot figure out how to do it. Can anybody be so kind as to post a code snippet? Cheers AndyI'm assuming the data returned is standard text, you can do something like: CString strMyString = reinterpret_cast(&pkt_data[14]);
-
Hi i wonder if anybody can answer this (simple?) question, i have a buffer returned from a library call declared as:
const UCHAR* pkt_data
and i want to fill a CString object from a certain postion from that buffer, say 14 charachers in, I have looked at all the CString articles here and for the life of me cannot figure out how to do it. Can anybody be so kind as to post a code snippet? Cheers AndyHow about:
CString str;
strcpy(str.GetBuffer(###), ...);
str.ReleaseBuffer();You might also be able to use
CString
's assignment operator, but I've not tried it so I can't say for sure.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Hi i wonder if anybody can answer this (simple?) question, i have a buffer returned from a library call declared as:
const UCHAR* pkt_data
and i want to fill a CString object from a certain postion from that buffer, say 14 charachers in, I have looked at all the CString articles here and for the life of me cannot figure out how to do it. Can anybody be so kind as to post a code snippet? Cheers AndyThe type UCHAR* and the name pkt_data sugest this is probubly a pointer to binary data, in which case you should be using a CByteArray. If you know the data you wish to copy has no bytes equal to zero and you still want to copy it to a CString then the sipilest way is as follows:
// assumes non-UNICODE version of program
CString str;
for( int i=0; i<14; ++i )
{
str += (char)pkt_data[i];
}INTP