I was trying to write a program that takes an input from a file which is located in Desktop not the default directory where the program is saved
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
int main()
{
ifstream fin;
string str="C:\Documents and Settings\shankhs\Desktop\ccs\Assignment CCS.txt",temp="";
cout<<str<<endl;
for(int i=0;i<str.size();i++)
{
if(str[i]=='\\')
temp+="\\";
temp+=str[i];
cout<<str[i]<<endl;
}
cout<<temp<<" "<<str<<endl;
fin.open((char *)&str,ios::in);
if(!fin)
cout<<"Cant";
else
cout<<"can";
system("pause");
return 0;
}
The escape character '\' is causing a lot of trouble as '\' is not taken by the variable since its a special character (I have taken input in str but actually I have to take it from user who will just copy and paste the path and filename) how to get out of this mess????
PLZ HELP!