Reading all files in a directory in an alphabetical order
Hi all,
I want to read all the files in a directory alphabetically . How can i achieve it ? Can i use the "readdir" function ? |
Which programming languages are you considering?
|
You can use readdir, sure, but you would still need to code the sorting yourself.
scandir() is more convenient when you need to sort. At the end of man 3 scandir there's example code which is a ready-made program to read a directory sorted alphabetically. |
for a quick lazy solution
you could cheat and use popen Code:
#include <stdio.h> |
Thanks for your replies
@catkin i am using C |
Quote:
|
Quote:
that's portable enough for me :) |
Thank you all for the replies ...
I checked both the solutions and they are working fine for me |
All times are GMT -5. The time now is 04:32 PM. |