in the program i am creating a file with specific path.. file name is to be entered by user and then we have to create a file but the code is giving the error written after the code.
void f_Createfile()
{
string dirpath; // stores final name for file with path to stored
string file_name; // to enter the name of file enter by user
cout<<"please enter the file name\n";
cin>>file_name;
dirpath.append("d:\\"); // appending the string by necessary terms
dirpath.append(file_name);
dirpath.append(".txt");
ifstream infile;
infile.open(dirpath,ios::in); // opening the file with dirpath string.. this line is showing error
if(infile)
{
cout<<"\nfile already exist\n";
infile.close();
f_menu();
}
else
{
cout<<" creating file...\n";
ofstream onfile;
onfile.open(dirpath,ios::app);
cout<<"\nfile is created:\n";
onfile.close();
}
}
Error 3 error C2664: 'void std::basic_ifstream<_Elem,_Traits>::open(const wchar_t *,std::ios_base::openmode,int)' : cannot convert parameter 1 from 'std::string' to 'const wchar_t *' c:\Documents and Settings\malaya\My Documents\Visual Studio 2008\Projects\assignment2\assignment2\assignment2.cpp 290