Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

demonrealms

WHY DOEN'T THIS THING WORK??!

This topic is 5731 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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 !

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!