IT창고/MFC
-
MFC 로 구현한 문자열 단어단위 역순 출력IT창고/MFC 2008. 2. 13. 15:01
CString str; CString token; CStringArray rev_str; int curPos= 0; str.Format(_T("Do or do not. there is no try")); str.MakeReverse(); while ((token = str.Tokenize(" ", curPos)) != "") { rev_str.Add(token); } int ndx = rev_str.GetSize(); CString result; CString word_format; while(ndx) { word_format.Format("%s ", rev_str[ndx-1]); result += word_format; ndx--; } AfxMessageBox(result);
-
CString -> char *IT창고/MFC 2007. 1. 22. 23:05
CString -> char * CString spi = _T("123"); char temp[100]; WideCharToMultiByte(CP_ACP, 0, spi.GetBuffer(spi.GetLength()) , spi.GetLength(), temp, spi.GetLength(), NULL, NULL); i_spi = atoi(temp); char * --> CString char ss[] = "Hello"; CString str; str.Format("%s", ss); (Format대신에 GetBuffer()를 써도 됩니다.)
-
-