Mail Archives: djgpp/1998/11/05/11:58:23
On Thu, 5 Nov 1998, Marc Brooker wrote:
> I need to write a simple program to count the files in a directory, I
> am currently using a program that is passed
> count *.*
> and it outputs the number of arguements, is there a better way to do
> this?
I think this is the best way, unless this is a class assignment and they
actually want you to write some code that accesses the directory.
Note that in DJGPP, *.* only expands to files that actually have an
extension. If you want all files, use just * without the dot and the
second asterisk.
Another gotcha is that this will not count files with hidden/system
attributes, since the startup code that expands the wildcards skips them.
(There are ways to force it to not skip them, in case you need that.)
- Raw text -