How to put two backslash in C++

前端 未结 5 1577
北海茫月
北海茫月 2021-01-15 19:48

i need to create a function that will accept a directory path. But in order for the compiler to read backslash in i need to create a function that will make a one backslash

5条回答
  •  日久生厌
    2021-01-15 20:03

    lots wrong. did not test this but it will get you closer http://www.cplusplus.com/reference/string/string/

    string stripPath(string path)
    {       
            string newpath;  
              for (int i = 0; i <= path.length() ;i++)
                {
                    if(path.at(i) == '\\')
                    {
                       newpath.append(path.at(i));
                       newpath.append(path.at(i));
                    }
                    else
                       newpath.append(path.at(i));
                }
            return newpath;
    } 
    

提交回复
热议问题