Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dirent.h

Status
Not open for further replies.

amarg

Programmer
Nov 19, 2002
106
IN
Hi All,

I am using the opendir(), readdir(), and closedir() to handle a directory.

According to man page of readdir(), should retrun the files in sorted order. I mean field d_name[] in struct dirent retruned by readdir() should contain the file name which is next in the sorted list of files. But i am getting something else. Please clear me related to the use of readdir().

I have the files in dir

(00.00.htm, 00.01.htm, 00.02.htm, 00.03.htm, 01.00.htm, 01.01.htm ............)

i am accepting the same sequence return by readdir().

But i am getting

(00.02, 00.03, 01.00.htm, 01.01.htm ............, 00.00.htm, 00.01.htm).

I know i am doing some mistake by what.........


Regards,
Amar
 
> According to man page of readdir(), should retrun the files in sorted order
I've read many different manual pages on readdir(), yet I don't recall any mention of sorting.

I read all the filenames into an array of some sort, then use the qsort() library function to sort the data however I want.


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top