String without seperators to array

Hi!

Just need help with this simple code.

I have to convert a string like this: "0010100010111".

To an array like this: array(0,0,1,0,1,0,0,0,1,0,1,1,1).

Thanx!

If each item is a single byte then it is easy

for (n = 0; n < 13; n ++) {
   myArray[n] = mystring[n];
}

if you want the values in the array to be numbers (rather than characters) you could do

myArray[n] = mystring[n] - '0';

…R

I have to convert a string like this: "0010100010111".

Is it a string (an array of chars terminated with zero) or a String (an object created using the String library) ?

How was it created ?

String str = String();

It worked Great! thank you for the help!

brandon_lane: String str = String();

And how did the String become "0010100010111" ? What I have in mind is that if you do not need the String for anything else then you might just as well populate the array instead in the first place.