c++ - ofstream writing data to file: How do I pass a previously defined string as the filename -
i have programme have written c++, opencv , qt, trying write info csv file. in qt widget have created qfiledialog allows me take save csv file.
this path stored qstring, , converted std::string follows;
std::string outputfilename = outputfile.toutf8().constdata(); i seek pass std::string ofstream::open function follows:
ofstream csvfile; csvfile.open(outputfilename); and there lies problem; refuses compile, giving error
no matching function phone call 'std::basic_ofstream >::open(std::string&)'
i'm new programming , have no thought problem here. have tried looking @ this, can tell windows specific solution, , using osx.
can tell me how can pass filepath stored in qstring csvfile.open() term?
in c++03, ofstream::open takes const char* parameter.
if outputfilename std::string.
try:
csvfile.open(outputfilename.c_str()); if outputfilename qstring
csvfile.open(outputfilename.tostdstring().c_str()); see qstring::tostdstring reference
c++ string csv ofstream qstring
No comments:
Post a Comment