title: How to create a dynamic filename for an SD card on Arduino
body: <p>I'd like to log my data on my Arduino one file at a time. I'd like the filename to be a combination of the number of milliseconds that have passed + some ID. For example, GPS data would be millis()+"GPS".</p>
  
  <p>I tried the following code, but it doesn't like the fact that I am using a <code>String</code>. I could use a char array, but the length would always be dynamic. Is there a way to do this with at string somehow?</p>
  
  <pre><code>static void writeToSD()
  {
      String logEntry = " GPS: ";
      logEntry += GPSString;
      String filename = String(millis());
      filename += "GPS";
      Serial.println(logEntry);
      Serial.println(filename);
  
      File dataFile = SD.open(filename, FILE_WRITE);
  
      // If the file is available, write to it:
      if (dataFile) {
          dataFile.println(logEntry);
          dataFile.close();
          Serial.println("Closed");
      }
      // If the file isn't open, pop up an error:
      else {
          Serial.println("error opening file");
      }
  }
  </code></pre>