Jump to content
  • Advertisement
Sign in to follow this  

C_str error

This topic is 3043 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

When I try to compile this:

void copy(int a){
stringstream profile;
char profilepath[50];
profile <<"xcopy " << profilepath << "/appdata/roaming/.minecraft/saves/world" << a << " /world" << a << "/s";
cout << "Copied files successfully. Press any key to exit";
GameRunning = false;

I get
1>c:\badprogramer\minecraft helper\minecraft helper\main.cpp(60) : error C2039: 'c_str' : is not a member of 'std::basic_stringstream<_Elem,_Traits,_Alloc>'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]

I am trying to make a program that copies files, but this has set me back. Help is appreciated.

Share this post

Link to post
Share on other sites
c_str is a member of std::string, not std::stringstream.

You want to write profile.str().c_str(), which first gets a string from the string-stream, and then gets a c-string from the string.

[edit]Ninja'd =)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!