hi i've never posted here before but ive got a problem and none of my friends could help me figure it out. basically i have a variable called fileloc, its a string entered by the user. my problem is how to i make this string the location where the file is written to. here is the part of my code in question
and this is the error i get:Code:#include <iostream> #include "Rectangle.h" #include <string> #include <fstream> using namespace std; #include <iomanip> // given to me by the tutor in room 320 int main() { Rectangle r; float l; float w; char answer; string fileloc; ofstream output; //program info output<<fixed<<showpoint<<setprecision(1); cout<<"This is the rectangle program designed to find the perimeter and area of "<<endl <<"rectangles of custom length and width which is input by the user and"<<endl <<"finally print the output to a user selected file"<<endl<<endl; // ask the user where to save it cout<<"Where would you like to save the output file"<<endl; getline(cin,fileloc); //open the file output.open(fileloc, ios::out);
..\..\program 2\program 2\project 2.cpp(39) : error C2664: 'void std::basic_ofstream<_Elem,_Traits>:pen(const wchar_t *,std::ios_base:
penmode,int)' : cannot convert parameter 1 from 'std::string' to 'const wchar_t *'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
im not very good at c++ (still learning) so maybe i have made a stupid mistake but any help would be awesome thanks in advance



LinkBack URL
About LinkBacks
pen(const wchar_t *,std::ios_base:


