Question about the array compare

If you insist on doing this with strings, then try this:


void currentDAY_compare() {
  for (int j = 0; j < 7; j ++) {
    if (strcmp(currtweekDAY[0], SDFoldersB0[j]) == 0) {
      CMDDAYmark = j;

      Serial.print("100SDFoldersB0[j] =");
      Serial.println(SDFoldersB0[j]);

      Serial.print("103 j =");
      Serial.println(j);

    }
  }
}

Although it is much simpler to just do something like this:

void printLocalTime() {
  struct tm timeinfo;
  if (!getLocalTime(&timeinfo)) {
    Serial.println("Failed to obtain time");
    return;
  }
  Serial.print("numeric day of week: ");
  Serial.println(((timeinfo.tm_wday) + 6) % 7); //convert start of week from Sunday to Monday
  Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S");
}
1 Like