Extracting a specific sequence of characters from an array I have a character array called storebuffer that contains data from a POST submission and its in the format ssid=abcdef&amp;pswd=ghijk. I wanted to extract everything after ssid= into one array called acqSSID and the portion after &amp;pswd= into another array called acqPaswd. I tried using this but it does not seem to be working. MAX_STORE_BUFFER_LEN is 255. Can anyone help?

int ctr = 0;
for (ctr = 5; ctr &lt; MAX_STORE_BUFFER_LEN; ctr++)
{
  if ( (storebuffer[ctr] == '&amp;') &amp;&amp; (storebuffer[ctr+1] == 'p') &amp;&amp; (storebuffer[ctr+2] == 's') &amp;&amp; (storebuffer[ctr+3] == 'w') &amp;&amp; (storebuffer[ctr+4] == 'd') &amp;&amp; (storebuffer[ctr+5] == '=') )
  {
    break;
  }
  acqSSID[ctr] = storebuffer[ctr];
}

Serial.print("acqSSID: ");
Serial.println(acqSSID);
Serial.print("ctr: ");
Serial.println(ctr);
You can simply chop it up in place without requiring more than a few extra bytes of RAM using strtok():

char storebuffer[] = "ssid=abcdef&amp;pswd=ghijk";

// Slice it into two parts around the &amp;:
char *lefthalf = strtok(storebuffer, "&amp;");
if (lefthalf != NULL) { // We found a &amp; and split the string OK
    char *righthalf = strtok(NULL, "&amp;");

    // Now you can slice each half around the =
    char *ssidtag = strtok(lefthalf, "=");
    char *ssid = strtok(NULL, "=");
    char *pswdtag = strtok(righthalf, "=");
    char *pswdtag = strtok(NULL, "=");

    Serial.print("SSID: ");
    Serial.println(ssid);
    Serial.print("Password: ");
    Serial.println(pswd);
}


The existing string gets chopped up and the pointers point to different places:

ssid\0abcdef\0pswd\0ghijk
^     ^       ^     ^
1     2       3     4

1: ssidtag
2: ssid
3: pswdtag
4: pswd