delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/05/11:58:23

Date: Thu, 5 Nov 1998 18:58:16 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Marc Brooker <quazar AT freemail DOT co DOT za>
cc: djgpp AT delorie DOT com
Subject: Re: Files In A Directory
In-Reply-To: <354f26ae.3464260@ct-news.iafrica.com>
Message-ID: <Pine.SUN.3.91.981105185419.7106M-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019