CString to char *



- CString to char*

1. memcpy
CString str = "test";
unsigned char st[30];
memcpy(st, (unsigned char*)(LPCTSTR)str,str.GetLength());

2. strcpy
CString strData = "test";
int length = strData.GetLength();
char* st = new char[length];
strcpy(st, strData.GetBuffer(0));

3. Type convert
CString str;
str = "test";
char* st = LPSTR(LPCTSTR(str));


- char* to CString
Using Format function in CString class
char st[] = "test";
CString str;
str.Format("%s", st);

Comments

Popular posts from this blog

(OpenCV Study) Background subtractor MOG, MOG2, GMG example source code (BackgroundSubtractorMOG, BackgroundSubtractorMOG2, BackgroundSubtractorGMG)

OpenCV Stitching example (Stitcher class, Panorama)

AMP dose run on my pc?, AMP(Accelerated Massive Parallelism)

Example source code of extract HOG feature from images, save descriptor values to xml file, using opencv (using HOGDescriptor )

Optical Flow sample source code using OpenCV

Real-time N camera stitching Class.

OpenCV meanShiftFiltering example source code ( cpu: pyrMeanShiftFiltering, gpu:meanShiftFiltering, gpu:meanShiftSegmentation )

8 point algorithm (Matlab source code) / The method to get the Fundamental Matrix and the Essential matrix

Video Stabilization example source code, (using cvFindHomography, cvWarpPerspective functions in openCV)

Image warping (using opencv findHomography, warpPerspective)