码迷,mamicode.com
首页 > 编程语言 > 详细

C++ 把文件路径中的单斜杠“\”换成双斜杠“\\”

时间:2018-01-17 00:30:14      阅读:569      评论:0      收藏:0      [点我收藏+]

标签:test   rar   body   microsoft   pos   basic   turn   头文件   mes   

 1 <pre name="code" class="cpp">
 2 #include <iostream>   
 3 #include <algorithm>  //必需加这个头文件  
 4 #include <string>  
 5 using namespace std;   
 6    
 7    
 8 int main()  
 9 {  
10        string::size_type pos=0;  
11        string test="fsffsfd\\fdsfsfd\\fdsfsd";  
12        cout<<test<<endl;  
13    
14         while((pos=test.find_first_of(\\,pos))!=string::npos)  
15         {  
16             test.insert(pos,"\\");//插入  
17             pos=pos+2;  
18         }  
19     cout<<test<<endl;  
20    
21     return 0;  
22 }   

 

转自:http://blog.csdn.net/huixingshao/article/details/46910761

参考:https://msdn.microsoft.com/en-us/library/syxtdd4f.aspx#basic_string::find_first_of

 

C++ 把文件路径中的单斜杠“\”换成双斜杠“\\”

标签:test   rar   body   microsoft   pos   basic   turn   头文件   mes   

原文地址:https://www.cnblogs.com/zhengfa-af/p/8297182.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!