Strange results for char *entryName

You defined entryName as a pointer to a single character.

Wrong. entryName is defined as a variable of type pointer to char. There is no type "pointer to char array".

A variable of type pointer to char points to one char - the first one in the array. The pointer can be incremented to point to each subsequent character.

The problem with the original code is that the pointer continues to point to memory that has gone out of scope when the function ends. Using it after that happens will NOT produce valid results.

I think what you actually want is:

If the idea is to have the name of next file available for use after nextFile() ends, then you are correct that OP needs to make a copy of the data.