WHY DOEN'T THIS THING WORK??!
I can''t figure put why, but this code won''t work. This is what I''m doing:
string path = "webmaker/projects/";
string path2 = input2;
string fullpath = path + path2;
cout << "What would you like the name to be??" << endl
<< "Project name can only be up to 10 charactors!" << endl
<< ": ";
cin.getline(input2, 10);
// path1
cout << "Creating nesessary files and directories" << endl;
CreateDirectory( _T( fullpath ), NULL );
CreateDirectory( _T( "webmaker/projects/tower" ), NULL );
ofstream file_02("main.data");
file_02.close();
ofstream file_03("description.txt");
file_03.close();
return(main());
This is the error i get: --------------------Configuration: webmaker - Win32 Debug--------------------
Compiling...
webmaker.cpp
C:\demonrealms\webmaker.cpp(64) : error C2664: ''CreateDirectoryA'' : cannot convert parameter 1 from ''class std::basic_string,class std::allocator >'' to ''const char *''
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
webmaker.obj - 1 error(s), 0 warning(s)
Why won''t it let me add path + path2 and put it in the directory path? I need it to work.
it looks like you can''t pass a std::string into CreateDirectory. It wants a pointer to a char, i.e. a C style character array. You need to put fullpath.c_str() to convert the std::string to a C style array. that''s one of the clearer error messages that compilers spew out !
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement