1. CString to const char*

 

CString strText = _T("myStirng");
const char* ccText;
ccText = (CStringA)strText;

 

 

 

2. const char* to CString

const char* ccText = "myString";
CString strText;
ccText = (CString)strText;

 

 

 

 

반응형

https://github.com/okigan/dcmtk/blob/master/dcmdata/include/dcmtk/dcmdata/dcuid.h



/** creates a Unique Identifer in uid and returns uid.

 *  uid must be at least 65 bytes. Care is taken to make sure

 *  that the generated UID is 64 characters or less.

 *  If a prefix string is not passed as the second argument a

 *  default of SITE_INSTANCE_UID_ROOT (see below) will be used.

 *  Otherwise the supplied prefix string will appear at the beginning

 *  of uid.

 *  The UID is created by appending to the prefix the following:

 *       the host id (if obtainable, zero otherwise),

 *       the process id (if obtainable, zero otherwise),

 *       the system calendar time, and

 *       an accumulating counter for tis process.

 *  @param uid pointer to buffer of 65 or more characters in which the UID is returned

 *  @param prefix prefix for UID creation

 *  @return pointer to UID, identical to uid parameter

 */


DCMTK_DCMDATA_EXPORT char *dcmGenerateUniqueIdentifier ( char *uid, const char* prefix = NULL );




#include "dcmtk/dcmdata/dcuid.h"


....


char *uid = NULL;

dcmGenerateUniqueIdentifier(uid);


.....

반응형




CString strTest = _T("Test");


const char *pTest = (CStringA)strTest;


CStirng strTest2 = (CString)pTest;





//////////////////////////////////////////////////////////////////////////////////



유니코드의 경우 아래의 방법을 참조.



CString -> char*


CString str = _T("권오철");

 char *buffer = new char[str.GetLength()];

 

strcpy(buffer,CT2A(str));

buffer;


delete buffer;

 


String -> char*


char ch[100];


strcpy(ch,(LPSTR)(LPCTSTR)"나는 누구인가?");



CString -> BYTE


BYTE msgProxy.byData;


CString strText = _T("ㅇㅇㅇ");


memcpy(msgProxy.byData,T2CA(strText), nLen);


BYTE byBuffer[100];


CString strText = _T("DDD");


strcpy((LPSTR)byBuffer,T2CA(strText));

  m_SocketManager.WriteComm( byBuffer, nLen, INFINITE);

 


char * -> CString


CString str = (LPCTSTR)(LPSTR)char *  // 이방법은 좋지 않다 .. 글씨가 깨진다


char getMessage[100] = "나는 천재인가";

 CString strMessage;

 strMessage.Format(_T("%s"),CA2T(getMessage));


출처 : https://blog.naver.com/sharp57/60117786558

반응형

+ Recent posts