Sign in to follow this  

string buffer to 2d array

Recommended Posts

I am reading from and xml document using c++.

<child> 1 2 3 4 5 6 7 8 9 10 </child>

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[/color]; 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};[/color]

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this