01-23-2011
9,926,
461
Join Date: Aug 2001
Last Activity: 26 February 2016, 12:31 PM EST
Location: Ashburn, Virginia
Posts: 9,926
Thanks Given: 63
Thanked 461 Times in 270 Posts
Remember that a directory is a list of filenames, it is not the files themselves. The readdir, telldir, seekdir functions are for processing a directory. That said, I have never used seekdir (or telldir) for anything. I rather doubt that I ever will. I really can't construct any hypothetical situation where they might be useful.
But if you wanted to write a C program that did the equivalent of "ls /etc", you would opendir() /etc, use readdir() to read the filenames, sort those filnames, and then display them.
When you got to,say, passwd, you could do a telldir() to remember this location in the directory. Then you could use readdir say 5 more times to read the next 5 filenames. Now you could use seekdir to go back to that entry for the file called passwd. Why you would want to do that beats me.