From: Richard Dawe Newsgroups: comp.os.msdos.djgpp Subject: Re: dir problems Date: Sat, 15 Mar 2003 17:53:24 +0000 Lines: 38 Message-ID: <3E736894.47A6A34@phekda.freeserve.co.uk> References: NNTP-Posting-Host: 62.136.12.118 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news8.svr.pol.co.uk 1047753050 12357 62.136.12.118 (15 Mar 2003 18:30:50 GMT) NNTP-Posting-Date: 15 Mar 2003 18:30:50 GMT X-Complaints-To: abuse AT theplanet DOT net X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586) X-Accept-Language: de,fr To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello. costa wrote: > Is there a way to duplicate a value given back by readdir ? > I want to store them in a struct wich is : > > typedef struct FileList { > > char *FileName; > char *FileType; > int pos; > struct FileList *pNext; > > }FileList; > > any pointers would be helpfull. info libc alpha readdir What do FileType and pos represent? Untested code to copy stuff from a DIR to a FileList: int dir2filelist (FileList *filelist, const DIR *dir) { /* NB: Assumes filelist needs initialisation. */ memset(filelist, 0, sizeof(*filelist)); filelist->FileName = malloc(dir->d_namelen + 1); strcpy(filelist->FileName, dir->d_name); ... return(filelist); } Regards, -- Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]