Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!jarthur!uunet!bria!mike From: mike@bria.UUCP (mike.stefanik) Newsgroups: comp.lang.c Subject: Re: File listing for current directory under Unix? Message-ID: <261@bria.UUCP> Date: 9 May 91 21:30:16 GMT References: <689@generic.UUCP> <1991May7.204403.2103@ux1.cso.uiuc.edu> Reply-To: uunet!bria!mike Organization: MGI Group International, Los Angeles, CA Lines: 22 In an article, gordon@osiris.cso.uiuc.edu (John Gordon) writes: >marekp@pnet91.cts.com (Marek Pawlowski) writes: > >>Does anyone know of a way to get the filenames of the files in the current >>directory, in to a two dimensional array of sorts? > > Yes. do a: popen("ls *", "r"); Actually, this will only work on UNIX-based systems, or perhaps DOS that has MKS tools or a facsimile thereof. Generally, this is operating system dependant and therefore the question is best posted for the particular os in question. As an aside, the use of popen() for this purpose is rather ungainly. Using readdir() would have been a better suggestion. -- Michael Stefanik, MGI Inc, Los Angeles | Opinions stated are never realistic Title of the week: Systems Engineer | UUCP: ...!uunet!bria!mike ------------------------------------------------------------------------------- If MS-DOS didn't exist, who would UNIX programmers have to make fun of?