Jump to content
  • Advertisement

Archived

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

std::string manipulation

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

How would i scan a std::string for a certain character, and then copy from that character and on into a new string? Im asking because i''ve implemented RLE into my map saving routine, which stores repeats by tile.id, something like 5:42, and im trying to load it properly, and i need to check the strings to see if they contain : and then get the number out of it. Any help would be apprecitated

Share this post


Link to post
Share on other sites
Advertisement
This looks like it would work:
size_type find(charT c, size_type pos = 0) const

So, this should work:

string temp;
int position=temp.find('':'',0);

Now position should contain the position of the first '':''. If you need the second just use the position as the second argument (where to start)

Share this post


Link to post
Share on other sites
quote:
Original post by TravisWells
If you need the second just use the position as the second argument (where to start)


position + 1, and only if it was not equal to std::string::npos - which means the character wasn''t found.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!