reality displays
reality displays

Reputation: 751

readdir function is not working as I had expected

Hi I am trying to write a program which uses readdir but the entries I read are not in sorted order.What else should I look for.

Upvotes: 0

Views: 350

Answers (2)

jilles
jilles

Reputation: 11212

Try scandir which reads the whole directory at once and can sort the names for you.

Upvotes: 1

RedX
RedX

Reputation: 15165

It is a Filesystem decision in what order it gives you the files or directories. If you want to display them sorted, you must first query all entries then sort them.

Upvotes: 0

Related Questions