I need to append file path for some particular program. But the problem is when I append it like below, it gets error whether filepath seems to be C:/Users/My/Desktop/C++/1.txt
1 2 3 4 5 6 7 8
int i=1;
stringstream str;
str<<"C:/Users/My/Desktop/C++/"<<i<<".txt";
string filepath=str.str();
cout<<filepath;
ifstream ipf(filepath);
if(ipf)
{ do some thing...}
But if it was like this no error, program work as desired.
1 2 3 4 5 6 7 8
int i=1;
stringstream str;
str<<"C:/Users/My/Desktop/C++/"<<i<<".txt";
string filepath=str.str();
cout<<filepath;
ifstream ipf("C:/Users/My/Desktop/C++/1.txt");
if(ipf)
{ do some thing...}
Not really, they are two completely different characters. \ is a backslash (escape sequence) and / is a forward slash. It's almost like saying r and c are the same letter.
Thank you for all replies.. my problem has been solved.
I have already tried using double back-slashes & forward back slashes. But problem was not solved.