This line is working
ifstream file("/home/pi/Desktop/DMixer_Webinterface_Downloadfile/Testing_Read.txt");
I split the path to 2 string
string path = "/home/pi/Desktop/DMixer_Webinterface_Downloadfile/";
string dicfile = "Testing_Read.txt";
Combine them
ifstream file("\""+path+dicfile+"\"");
It have error that
testing030320170800.cpp: In function ‘int main()’:
testing030320170800.cpp:3221:38: error: no matching function for call to ‘std::basic_ifstream<char>::basic_ifstream(std::basic_string<char>)’
ifstream file("\""+path+dicfile+"\"");
^
testing030320170800.cpp:3221:38: note: candidates are:
In file included from testing030320170800.cpp:17:0:
/usr/include/c++/4.9/fstream:470:7: note: std::basic_ifstream<_CharT, _Traits>::basic_ifstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]
basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in)
^
/usr/include/c++/4.9/fstream:470:7: note: no known conversion for argument 1 from ‘std::basic_string<char>’ to ‘const char*’
/usr/include/c++/4.9/fstream:456:7: note: std::basic_ifstream<_CharT, _Traits>::basic_ifstream() [with _CharT = char; _Traits = std::char_traits<char>]
basic_ifstream() : __istream_type(), _M_filebuf()
^
/usr/include/c++/4.9/fstream:456:7: note: candidate expects 0 arguments, 1 provided
/usr/include/c++/4.9/fstream:430:11: note: std::basic_ifstream<char>::basic_ifstream(const std::basic_ifstream<char>&)
class basic_ifstream : public basic_istream<_CharT, _Traits>
^
/usr/include/c++/4.9/fstream:430:11: note: no known conversion for argument 1 from ‘std::basic_string<char>’ to ‘const std::basic_ifstream<char>&’
Updated Code * Previous compilation error solved
string path = "/home/pi/Desktop/DMixer_Webinterface_Downloadfile/";
string dicfile = "Testing_Read.txt";
cout << (("\""+path+dicfile+"\""));
//ifstream file("/home/pi/Desktop/DMixer_Webinterface_Downloadfile/Testing_Read.txt");
ifstream file(("\""+path+dicfile+"\"").c_str());
std::string str;
while (std::getline(file, str,','))
{
myArray[array_count] = str; // store those value in array
cout << str << "\n";
strings.push_back(str);
array_count++;
}
By using this line I can print out the content of the text file
ifstreamfile("/home/pi/Desktop/DMixer_Webinterface_Downloadfile/Testing_Read.txt");
But, after using combination the directory path and put to the ifstream method, it cannot read the content of the text file, BOTH compilation no error