Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!sdd.hp.com!wuarchive!uunet!mcsun!ukc!pyrltd!root44!gwc From: gwc@root.co.uk (Geoff Clare) Newsgroups: comp.lang.c Subject: Re: File listing for current directory under Unix? Message-ID: <2709@root44.co.uk> Date: 10 May 91 13:52:31 GMT References: <689@generic.UUCP> <1991May7.204403.2103@ux1.cso.uiuc.edu> Organization: UniSoft Ltd., London, England Lines: 23 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? gordon@osiris.cso.uiuc.edu (John Gordon) writes: > Yes. do a: popen("ls *", "r"); That won't do what was asked for if there are any subdirectories under the current directory. To do it with popen() you should use either popen("/bin/ls", "r"); or popen("/bin/ls -a", "r"); depending on whether you want to include files beginning with "." or not. As other people have already pointed out, it is much better to use opendir(), readdir() and closedir() if you have them. -- Geoff Clare (Dumb American mailers: ...!uunet!root.co.uk!gwc) UniSoft Limited, London, England. Tel: +44 71 729 3773 Fax: +44 71 729 3273