mfc copy certain sections of a CString

前端 未结 2 1479
难免孤独
难免孤独 2021-01-21 12:48

Let\'s say I have a CString variable carrying the string \"Bob Evans\". I want to copy from position 4 until the end of the original CString to a new CString, but I am having tr

2条回答
  •  温柔的废话
    2021-01-21 13:31

    It isn't all that hard to turn a CString into a standard string; the only glitch is that you're probably using Unicode if you take the default settings for your MFC program. That means you'll want to use std::wstring instead of std::string.

    I haven't tested this, but I think the default conversions will let this 'just work'. Otherwise cast the CString to LPCTSTR.

    std::wstring copyOfOriginal(original);
    

提交回复
热议问题