Hello, I'm trying to use the File class and really need some documentation. I'm using the SD example code in ListFiles sketch
File entry = dir.openNextFile();
if (! entry)
{
// no more files
Serial.println("**nomorefiles**");
break; // Finished !!
}
Serial.println(entry.name());
However, I want to copy the file name returned by entry.name() rather than print it to the Serial monitor but can't find any documentation on using the class File.
Well, of course you do. entry.name is a function. entry.name() is a call to a function that returns a value.
Making a copy of the pointer returned, as you are trying to do, will be a waste of time. When the pointed to value changes for one copy of the pointer, the pointed to value for the other will change, too.
strcpy() copies the pointed to data. strdup() creates another pointer, and memory that it points to, and copies the pointed to data there.