Jump to content
  • Advertisement
Sign in to follow this  
CyberSlag5k

Looking for quick insert and move function

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

Isn't there a version of memcpy or something that will insert an item into a buffer and move everything else down? so if I had the following string: 12345 and I wanted to insert 9 as the 3rd element, I'd get back 123945. is that what memmove does? MSDN's explanation is a little confusing. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by STLDude
Or you can just use std::vector and it will do all of that for you :)


sane pieice of advice but since he only mentioned memmove I guess we should work from the assumption that he's coding C :)

but yes, std::vector would handle that fine and if you do many random insertions and deletions std::list could be an even better alternative. That of course would require one of those modern C++ compiler thingmajigs.

Share this post


Link to post
Share on other sites
wouldn't std::string have some functionality like this, seeing as how it is a container? You should be able to insert any arbitrary substring into a string pretty quickly.

Share this post


Link to post
Share on other sites
I agree with Grizwald. The basic_string class has more .insert() members than you can shake a stick at. I'd go that way.

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.

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!