有个CString texts;内容:
hello!\n
erath!\n
our come form mars!\n每行都有回车,就像文本文件那样
现在想用CStdioFile的ReadString()那样去逐行读取。
不知道有何办法呢?
尽量不让CString的内容输出成为磁盘文件后,再让ReadString()去读取,因为执行时有可能在U盘里。
倒在内存里?第二个问题是算法问题,求出CString texts里,第32个回车后往回42个字符开始连续18个字符,这18个字符是什么内容?谢谢!

解决方案 »

  1.   

    用find(),找到位置,再处理
      

  2.   

    CString str="1234567\\n";
    int a=0;
    a=str.Find("\\n",0);
      

  3.   

    既然 内容都存到CString texts中了,那肯定也在内存中了,还和在不在U盘中有什么关系呢?
      

  4.   

    替换"\n",按照别的拆分也行,其实这个就是拆分字符串CString strSrc;//source string, read only
    CString strTmp;
    CString strLine;//current line
    int nIdx = 0;strTmp = strSrc;
    while ((nIdx = strTmp.Find("\n")) != -1)
    {
    strLine = strTmp.Left(nIdx);//get current line
    strTmp = strTmp.Right(strTmp.GetLength() - nIdx - strlen("\n"));
    }
    strLine = strTmp;//the last line