我有一个字符串CString a="d:\devlop\myvc60\runtogther\"
请问我怎样能将字符串里所有的"\" 转化为 "\\" ??????
                             thank you!!!

解决方案 »

  1.   

    a.Replace("\","\\");
    要不要引号自已试试,记不清楚了
      

  2.   

    char ch;
    CString b="";
    for(int i;i<a.Getlength();i++)
    {
         ch=a.GetAt(i);
         if('\\'==ch)
         {
              b+=ch;
              b+=ch;
         }
         b+=ch; }b 就是你想要得串
      

  3.   

    错了!应该是:
    a.Replace("\\","\\\\");
      

  4.   

    CString a="d:\\devlop\\myvc60\\runtogther\\";
    a.Replace( "\\" , "\\\\" );
    MessageBox( a );
      

  5.   

    CString a="d:\devlop\myvc60\runtogther\"(这样写本来就是错的)
      

  6.   

    要写成 CString a="d:\\devlop\\myvc60\\runtogther\\";