Char array operator doubt

Who can tell me what this line does? (the second one of course)

char filename[13] = "00000000.log";
filename[2] = year/10 + '0';

I mean, my doubt is about the + '0' part. I've been googling this and it appears in several sites but no one explains it. It might be too obvious? I suspect it's some kind of clever conversion to a char value, but as I'm trying to learn I want to know the very core of the operation.

Say that year/10 is 8.

Now if we put that into a filename, ASCII 0x08 is a backspace character. However 0x38 is ASCII '8'.

By adding '0' to the result (where '0' is 0x30) effectively it turns 0x08 into 0x38, which is what you want for a printable "8".

This program illustrates what Nick said:

void setup() {
  Serial.begin(9600);
  Serial.println("Enter two digits:");
}

void loop() {


  char temp[3];
  char filename[13] = "00000000.log";
  int charsRead;
  int year;

  if (Serial.available() > 0) {
    charsRead = Serial.readBytesUntil('\n', temp, 3);
    Serial.println(charsRead);
    if (charsRead == 2) {
      temp[2] = '\0';             // The input is now a string
      year = atoi(temp) / 10;     // Get the "tens of years" e.g., 80 years = 8 "tens"

      filename[2] = year + '0';   // Take ASCII code for zero and add year to it
      Serial.print("New filename is: ");
      Serial.println(filename);
    } else {
      Serial.println("I said TWO digits characters!");
    }
  }

}

Suppose you type in "80". This makes year equal the int value 8 after the divided by 10. The ASCII value for the character zero ('0') is 48. Therefore, year plus 48 = 8 + 48 = 56. If you look up the code for ASCII 56, you will see it is the character '8'. Note that 8 expressed as an int and the ASCII character for '8' are two different animals.

You can "reverse" the process, too. If you receive an ASCII '8' from the keyboard as a char variable named digit, then you can convert the char value entered to an int using:

int val = digit - '0'; // that is, 8 = 56 - 48;

Think about it.

So basically it's ASCII math in background. Actually it wasn't that obvious for me. Many thanks for the quick, precise answer.

javo8: So basically it's ASCII math in background. Actually it wasn't that obvious for me.

No, it isn't ASCII math, it's just regular arithmetic.