2
Reply

Convert string to X-dimensional array

Haraakesh Kumar

Haraakesh Kumar

Nov 30 2012 1:57 AM
3.2k
Hello! 
How do I convert a string, formatted as following:

string str="1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16"

to a multidimensional array, so that:

arr[0,0]=1
arr[0,1]=2
arr[0,2]=3
arr[0,3]=4
arr[1,0]=5
and so on.

The string can have different sizes.
Thanks!

Answers (2)