CString SText, SText0;
SText=_T("\n123");//_T("123\n");
if (!SText.Find("\n"))
SText0 = SText.Mid(SText.Find("\n") + 2, SText.GetLength()- 2);
else
SText0 = SText.Mid(0, SText.Find("\n"));

解决方案 »

  1.   

    不用太麻烦的;比如:
    CString ss=".......";
    ss.TrimLeft();
    ss.TrimRight();
      

  2.   

    xb4270293(阿发)的代码好像是有错,
    SText.Mid(SText.Find("\n") + 2, SText.GetLength()- 2);
    回车符和换行符并非是成对出现的!
    甚至可以有一个回车符两个换行符,或者两个回车符,一个换行符。或者没有回车符,只有换行符,你有兴趣可以试一试,在某种搭配下的文本文件是不能被记事本修改的,只要改动一个字,整篇文章就成一堆了!我也是偶然发现的。我的意见是
    for(int i=0;i<str1.GetLength();i++)
    {
       TCHAR ch = str1.GetAt(i);
       if(ch != '\n')
         str2 += ch;
    }这样,无论换行符在哪里,都可以搞定的!
      

  3.   

    Replace(expression, find, replacewith[, start[, count[, compare]]])
    Arguments
    expression 
    Required. String expression containing substring to replace. 
    find 
    Required. Substring being searched for. 
    replacewith 
    Required. Replacement substring. 
    start 
    Optional. Position within expression where substring search is to begin. If omitted, 1 is assumed. Must be used in conjunction with count. 
    count 
    Optional. Number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions. Must be used in conjunction with start. 
    compare 
    Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. If omitted, the default value is 0, which means perform a binary comparison. 
    查查msdn吧
      

  4.   

    Tasehouny(阿甘)的方法很好,不好意思,我向来给分比较集中