Thanks, strlen() was a helpful tip.
About the copying of the name, I tried this
int actFile = 0;
char *actFilename = NULL;
while(root.readDir(dirBuf) > 0) {
int actSize = 0;
while(dirBuf.name[actSize] != 0 && dirBuf.name[actSize] != 87 && dirBuf.name[actSize] != 32) {
actSize++;
}
if(actSize > 0) {
actSize++;
actFilename = (char*) malloc(actSize * sizeof(char));
for(int i=0;i < actSize-1;i++) {
actFilename[i] = dirBuf.name[i];
}
actFilename[actSize-1] = 0;
allFilenames[actFile] = strdup(actFilename);
actFile++;
}
free(actFilename);
}
If I comment out
allFilenames[actFile] = strdup(actFilename);
and do Serial.print of actFilename[i] below actFilename[i] = dirBuf.name[i], it looks as it should, but with the strdup() line active, it breaks down again. So I suppose something is wrong with my actFilename?