Jump to content
  • Advertisement
Sign in to follow this  
Gink

Errors

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

not sure why this is generating errors string s = "ab2c3d7R4E6"; string num ="0123456789"; vector<string> a; int pos = 0; int nt; while((nt = s.find_first_of(num,pos)) != string::npos){ a.push_back(s[nt]); //invalid conversion from `char' to `const char*' pos = nt+1; }

Share this post


Link to post
Share on other sites
Advertisement
Well, if you're reffering to the line about the invalid conversion, I'd suggest you take a s.substr().c_str(). That would procuce a const char string to be copied into the vector. I don't know if you could even fo s[nt].c_str(). Maybe that would work. Check this site out: http://www.cppreference.com/index.html

Share this post


Link to post
Share on other sites
the [] operator returns a reference to a char, not a reference to a string. You could use

a.push_back(string(1,s[nt]));

instead.

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!