본문 바로가기

old drawer/C, C++, MFC

[MFC] CString에서 line by line으로 읽기

CString teststr = _T("Line1\nLine2\r\nLine3\nLine4");

CString outputstr;


for (int i = 0; i < teststr.GetLength(); i++)

{

if (teststr[i] == '\n')

{

MessageBox(outputstr, _T("String Parsing"), MB_OK);

outputstr = "";

}

else

{

if (teststr[i] != '\r') outputstr += teststr[i];

}

}