www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/26/17:45:02

From: Jean-Gaël GRICOURT <jean-gael DOT gricourt AT snet DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Readdir() function ?
Date: Tue, 26 Nov 1996 13:11:52 -0500
Organization: A customer of SNET Internet: http://www.snet.net/
Lines: 29
Message-ID: <329B32E8.793@snet.net>
Reply-To: jean-gael DOT gricourt AT snet DOT net
NNTP-Posting-Host: brpt01-sh1-port29.snet.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

The function readdir() from dirent.h doesn't seems to work very well ?

Try it with these arguments :

    - no argument -> memory fault.
    - arg="\"     -> don't list the root of the disk.
    - arg=".."    -> don't list the root if ".." is really linked to the
root.


#include <stdio.h>
#include <dirent.h>

void main(int argc,char **argv)
{
 DIR           *d;
 struct dirent *dr;

 if((d=opendir(argv[1]))!=NULL)
 {
  while((dr=readdir(d))!=NULL) printf("%s\n",dr->d_name);
  closedir(d);
 }
 else perror("opendir");
}



mailto://jean-gael DOT gricourt AT snet DOT net

- Raw text -


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