How is it possible to change "TheFile.txt" to a string instead.
I am trying to instead declare "TheFile.txt" like this but this doesn´t work. What could be wrong here.
Ifstream Onefile ("TheFile.txt");
File = "TheFile.txt"
Ifstream Onefile (File);
std::string File( "TheFile.txt" );
std::ifstream Onefile( File.c_str() );
that constructor expects a const char*. the cpompiler cannot convert from std::string to const char*.
ifstream OneFile (file.c_str()) is what you need. the c_str() member function of the std::string class returns your string as a const char*
Okay. I understand. This worked great. I will look at this.
That's because the poor thing lacks an overloded operator const char* as opposed to a real string class such as CString :rolleyes:
Originally Posted by Mario F.
I know I'm asking for trouble :D