Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!bu.edu!bu-cs!snorkelwacker!tut.cis.ohio-state.edu!cs.utexas.edu!yale!cs.yale.edu!geer-john From: geer-john@CS.YALE.EDU (John Yuson Geer) Newsgroups: comp.lang.c Subject: Re: all filenames in directory in array/list Message-ID: <14575@cs.yale.edu> Date: 7 Feb 90 02:33:26 GMT References: <5302@star.cs.vu.nl> Sender: news@cs.yale.edu Reply-To: geer-john@CS.YALE.EDU (John Yuson Geer) Organization: Yale University Computer Science Dept, New Haven CT 06520-2158 Lines: 36 In article <5302@star.cs.vu.nl> mstuurm@cs.vu.nl (Mark Stuurman) writes: >Could someone tell me how read all filenames in a directory into >an array or a list (of filenames of course). > "scandir" is what you seek. It even allocates the array of directory structures! #include #include #include main() { int num,i; struct direct **namelist; char dir[] = "/usr/bin/X11"; num = scandir(dir,&namelist,NULL,NULL); for(i=0;id_name); } > Many thanks in advance, > Mark Stuurman (mstuurm@cs.vu.nl) > >P.S. We use SunOS 4.0 no prob! jyg' --- geer@CS.YALE.EDU "This was because he was no mere dreamer but one readnews be news one of those dreamer-doers, a guy with a program." -_Henderson_the_Rain_King_ by Saul Bellow Hochspannung Lebensgefahr