Jump to content
  • Advertisement
Sign in to follow this  
pressgreen

string buffer to 2d array

This topic is 2554 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 am reading from and xml document using c++.

[color="#8b0000"]<parent>
<child> 1 2 3 4 5 6 7 8 9 10 </child>
</parent>

I have already created the parser that will read in the numbers on that line and store them in a buffer.
when i [color="#8b0000"]cout<<buffer<<endl; that buffer I get the numbers with the spaces. how do i store them into an 2d array? ex: [color="#8b0000"]buffer[]={1,2,3,4,5,6,7,8,9,10};

right now the numbers are stored as a string buffer,

any ideas with the logic on how to do this would be awesome thanks :)

Share this post


Link to post
Share on other sites
Advertisement
Generally XML is designed such that you don't need additional parsing on tag contents. That aside, you could fill a std::vector<int> by using a std::stringstream to re-parse the contents.

It won't be a 2d array, but I don't see how you're planning on building a 2d array from that data.

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!