2 dimensional array of chars.

Thanks everyone for your help it is appreciated.

I was writing a parsing function which handles double quotes too. It now works :slight_smile:

I'm new to C++ normally programming in assembler or Pascal (delphi)

char commands[5][20];

byte getwords(char s[30]){
  byte i=0;
  byte pos=0;
  byte numcommands=0;
  boolean inquotes=false;
  for (i = 0; i < 6; i++) {
    for (pos = 0; pos < 20; pos++) {
      commands[i][pos]=(char)0;
    }
  }
  pos=0;
  for (i = 0; i < 30; i++) {
    if (s[i]==NULL){break;}
    if (s[i]==(char)34){
      inquotes=!inquotes;
    } else {
      if ((s[i]==(char)32) && !inquotes){
        pos=0;
        numcommands++;
      } else {
        commands[numcommands][pos++]=s[i];
      }
    }
  }
  return numcommands+1;
}

I am trying to get my head round C++, is this written in the best way? Can anyone see anything that is best done another way?

Thanks for looking.