Split string for tv remote project

ok im making a TV remote using the following libary

this is far the best remote example i have found.

What i want to do is have a varible to set the channel without having loads of buttons or a large code .

example want to select channel 12 ..

say this sends "1" to the tv ( this the ir code 75531)
irsend.sendRC6(75531, 20);

and ..

say this sends "2" to the tv ( this the ir code 75532)
irsend.sendRC6(75532, 20);

so i want a varible: chan_to_set = 12

my method would be split "12" in two

send code for "1" wait a few secs and send the code for "2"

Can you split a number like "12" into 2 parts ?

would an array help ?

im really lost any help would be great thanks

luke

To convert the 2 digit int into 2 one digit ints:

int digit1 = chan_to_set / 10;
int digit2 = chan_to_set % 10;

If chan_to_set is a 3 digit in (greater than 99):

int digit1 = chan_to_set / 100;
int rest = chan_to_set % 100;
int digit2 = rest / 10;
int digit3 = rest % 10;

This can easily be expanded to handle 4 and 5 digit numbers. The intermediate variables are not necessary, but they improve readability.

thanks , that was just simple math . You hit the nail on the head many thanks again.

cheers
luke