Filename in SD.open

I tried to set a filename with date (montday,month,year) . The compile reject the variable name in sd.open.

Monitor_Chaudiere.cpp: In function ‘void ecriture_Log()’:
Monitor_Chaudiere.cpp:338:51: error: no matching function for call to ‘SDClass::open(String&, int)’
/usr/share/arduino/libraries/SD/SD.h:74:8: note: candidate is: File SDClass::open(const char*, uint8_t)
Is there a way to do that?

myFile = SD.open(dsname, FILE_WRITE);

dsname built as a string:
dsname = (" " ) ;
dsname += monthDay ;
dsname += “" ;
dsname += month ;
dsname += "
” ;
dsname += year ;
Thanks
Dominique

The compile reject the variable name in sd.open.

Yes, it did, because you used a String. So, don't do that. Use a string (NULL terminated array of char) and sprintf(), instead.

thks it works with that : sprintf(dsname,"%i-%i-%i",monthDay,month,year) ; but how to append .txt.

Thanks

but how to append .txt.

sprintf(dsname,"%i-%i-%i.txt",monthDay,month,year) ;

all is ok, thanks. Sorry I am very new with Arduino and don't really difference with string and char. Dominique