본문 바로가기
IT창고/MFC

MFC 로 구현한 문자열 단어단위 역순 출력

by 창구창고 2008. 2. 13.

📑 목차

    반응형

    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);

    반응형

    "이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."