Hi everyone, new here. I have a class in C++ and even my teacher can't figure this one out, so maybe someone here will spot something?
my error isCode:#include<iostream> #include<string> #include<fstream> using namespace std; int main() { string userName; ofstream outputFile; cout << "Please enter a file name to open." << endl; cin >> userName; outputFile.open(userName); cout << fileName << " is opened successfully!" << endl; return 0; }
please help!Code:1>------ Build started: Project: debug, Configuration: Debug Win32 ------ 1>Compiling... 1>debug.cpp 1>c:\users\skyler\documents\visual studio 2008\projects\debug\debug\debug.cpp(13) : error C2664: 'void std::basic_ofstream<_Elem,_Traits>::open(const wchar_t *,std::ios_base::openmode,int)' : cannot convert parameter 1 from 'std::string' to 'const wchar_t *' 1> with 1> [ 1> _Elem=char, 1> _Traits=std::char_traits<char> 1> ] 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>c:\users\skyler\documents\visual studio 2008\projects\debug\debug\debug.cpp(14) : error C2065: 'fileName' : undeclared identifier 1>Build log was saved at "file://c:\Users\Skyler\Documents\Visual Studio 2008\Projects\debug\debug\Debug\BuildLog.htm" 1>debug - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



LinkBack URL
About LinkBacks



