PaulS:
Is it the size of the pointer that you don't know (2 bytes) or the length of the string pointed to?
in reference to the comment-> // problem: I don't know the size
Scratch that. This was a comment out of ignorance, assuming the compiler needed to know the size of the a returned array that I now know isn't being returned.
An assumption rooted in seeing the function used like this -> Serial.println(myFile.name()) // no ref entry for .name()
PaulS:
Does the SD class support anything other than 8.3 format names? Don't you really already know the maximum length of the string?
Good point, so a max of 13 chars right? (8 for the name, one for the period, 3 for the extension, 1 for null)
PaulS:
Do you understand that that allocation and assignment will fail, since you can't assign a pointer to char array?
Thought it was returning the char array itself.
Guess bringing the string into another part of memory would be redundant if we have address to where it is already stored in memory. Please correct me if my understanding of pointers is wrong I haven't normally used them.
To exemplify my ignorance a little further I have to ask the question, does the name() returned pointer refer to an address on the SD card or one that has been loaded into ram already? (my assumption is ram because only 2 bytes are returned) In either case how would I go about addressing it in my function?
All I really need to is read each individual letter in the filename. Having the whole string at any given time is irrelevant to the function working so I don't really want to allocate memory for the whole string if I can avoid it. Every loop where a new letter is needed from the filename, myFile.name() will be called, at least in the way this function is used.
In that case can I just point to the next byte after the pointers address to get the second letter in the array?
Maybe I'm missing the concept completely or maybe seeing code examples would help would give me an ah ha moment.