Reading chars and storing into an array (!)

Hi! I'm playing with DTMF tones, using a MT8870 I decode tones to digital signals (binary code) and with some arduino code I parse it.

At this moment my loop function is:

void loop() {
    irqState = digitalRead(STD); //Get the first trigger tone
    if (irqState == 1) {
        char code = mapKey();
        Serial.println(code);
        delay(100);
    }
}

The thing is: I receive each decoded tone by triggering the irqState, So if I send 123 (three tones) I get 123, that is very nice!!! But now I want to 'store' it into an array to compare it later (to do some remote control stuff).

How can I do this?

Sorry for my english :~

http://arduino.cc/en/Reference/Array http://www.thebox.myzen.co.uk/Tutorial/Arrays.html

//Lets say you have an array:
char dtmf [20] 
int i = 0;

setup()
//some code

loop()
{
// some code
          irqState = digitalRead(STD);                //Get the first trigger tone
          if (irqState == 1)
          {    
                dtmf[++i]= mapKey();
                delay(100);
          }

// lets say an # starts iteration code thought dtmf[0] to dtmf[maximum] to process through the values
// don't forget to set i = 0 when you are ready to start capturing again.


} // END of loop
                dtmf[++i]= mapKey();

When i starts at 0, where are you storing the first value, Larry? Not in the 0 spot, where it belongs.

Larry, your solution works like a boss in my project, thanks!!!

I would think you'd want to start by placing the first item at 'dtmf[0]' and not 'dtmf[1]'

Try ...

dtmf[i++]= mapKey();

Yep! I did that change to start in 0 position.

Thanks