SD.open dynamic filename

Hi
Can you help me to find a solution for this.

I have 001-999.csv files on sd card, so I would like to open dynamically this files

void runTemplate()
{
  getCordsArray(001);
  ...
}


void getCordsArray(byte coords_file) {

  if (!csvRead) {
    SD.begin(SDCARD_PIN);
    String fileName =  coords_file + ".CSV";    
    file = SD.open(fileName.c_str(), FILE_WRITE);
    ...
  }
}

Thank you

char fn[13];
sprintf(fn, "%03d.CSV", coords_file);

berlogi:
I have 001-999.csv files on sd card, so I would like to open dynamically this files

void getCordsArray(byte coords_file) {

I see a problem with files 256-999.csv. :wink:

Thank you very much, can you tell me what means 13 ?

Thanks for your advise, changed it to int

Whandall:
I see a problem with files 256-999.csv. :wink:

berlogi:
Thank you very much, can you tell me what means 13 ?

13 is the size of the buffer for the 12 chars zero terminated string. 12 is the size of an 8+3 file name. I copied from code where a full length filename was build.