I've searched around and can't find out how to convert a string into an int array.
so that:
turns into:Code:string myString = "12345" ;
Code:int x[ 5 ] = { 1, 2, 3, 4, 5 } ;
Printable View
I've searched around and can't find out how to convert a string into an int array.
so that:
turns into:Code:string myString = "12345" ;
Code:int x[ 5 ] = { 1, 2, 3, 4, 5 } ;
might be easier to turn it into a vector
but look into copy algorithm in STL, or memcpy from C
not sure if this will compile... but here maybe
Code:int *x = new int[myString.length()];
copy(myString.begin(), myString.end(), x);
for(int i=0;i<myString.length();++i)
x[i] = x[i]-'0';
There is a post about a reverse string, same principal. I got it to work with a for loop and string.length().