Ajout de '\' dans une string
Bonjour j'ai une string contenant un chemin d'acc�s tu style "c:\toto\titi.txt"et j'aimerais doubl� le \ et avoir une chaine du style "c:\\toto\\titi.txt".
Comment faire ???
j'ai tout d'abort essayer avec le code de la faq c++ que j'ai modifi� pour mon besoin : http://c.developpez.com/faq/cpp/?pag...#STRING_tokens
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| string val;
string mot;
val = "";
string spath;
spath = path.substr(0,path.find('\n'));
istringstream iss( spath );
while ( getline ( iss, mot, '\' ) )
{
if(val == "")
{
val = mot;
}
else
{
val = val + "\\" + mot;
}
} |
mais j'ai une erreur :
Code:
1 2
| c:\dev\anamorphose\anamorphosedlg.cpp(333) : error C2001: newline in constant
c:\dev\anamorphose\anamorphosedlg.cpp(333) : error C2015: too many characters in constant |
une id�e ???