title: File name for file on Arduino SD card won't save
body: <p>I'm making a data logging system, just for fun and learning the language. If I want to save a variable ".txt" file with an INT it works fine. Now I bought an RTC and I want the name to be as following: "Data_'DATE&amp;TIME'.txt".</p>
  
  <p>As you can see in the code below, I made a function newFileName what should be doing this, but my output also below is nothing like it. And on the SD card nothing even saves. </p>
  
  <p>The things in comments are things I tried.</p>
  
  <pre><code>int CURRENT_FILE        = 1;
  String dataString       = "";
  String currentFileName  = "";
  String currentTimeStamp = "";
  
  void setDatumTijd(){
    t = rtc.getTime();
    currentTimeStamp = rtc.getDateStr();
    currentTimeStamp += "--"; 
    currentTimeStamp += rtc.getTimeStr();
    currentTimeStamp.replace(':', '.');
    delay(50);
  }
  
  void makeNewFile(String currentTimeStamp){
    char fileName[50];
    char timeStamp[20];
   // sprintf(timeStamp, currentTimeStamp.c_str());
    sprintf(fileName, "Data_%d.txt", currentTimeStamp.c_str());
    //currentFileName = fileName;
    //currentFileName.toCharArray(fileName,50);
    //currentTimeStamp += ".txt";
    //currentTimeStamp.toCharArray(fileName, (currentTimeStamp.length()+1));
    Serial.println(fileName);
    currentFileName = fileName;
    File dataFile = SD.open(fileName, FILE_WRITE);
    saveHeader(currentFileName, currentTimeStamp);
    dataFile.close();
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OZHUi.png" rel="nofollow noreferrer">enter image description here</a></p>