if(!SD.exists(date + ".txt")); How do I do this?

Didn't know really how to describe this in the subject line. I have:

char date[9]

which contains "13_01_21" (but this will obviously change each day) and I would like to have ".txt" appended to it in:

if(!SD.exists(date + ".txt")

so that it will be evaluated as:

if(!SD.exists("13_01_21.txt"));

What is the operator to do this?

There is a way to do this with String but String has bugs in it. You would be a lot better off to use a char array and sprintf - there are other ways too, such as using strcpy and strcat.

char filename[16];

  sprintf(filename,"%s.txt",date);
  if(!SD.exists(filename)) {
    // The file doesn't exist
  } else {
    // The file does exist
  }

Pete

Thanks! That is exactly what I needed.