After getting a DIR * using opendir(), I need to use readdir() to read and store the struct dirent into an array.
In order to figure out the size of the array, I could just loop through and count the entries. Then, I could allocate the array and then loop through again to read and store the struct dirent.
However, I'm wondering whether there is a better way to get the number of dir entries?
realloc
to grow it as necessary. – pat