Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!AIVAX.RADC.AF.MIL!marks From: marks@AIVAX.RADC.AF.MIL (David Marks) Newsgroups: comp.sys.sgi Subject: Re: problem with scandir Message-ID: <9104042019.AA21343@AIVAX.RADC.AF.MIL> Date: 4 Apr 91 20:19:26 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 43 [ Mail to originator bounced... How can info-iris always get the mail through..] Mark, First, I'm sure its a typo, but the structure name is "dirent" not "direct". Secondly, you have to provide a place for the directory information to go, not just a place for a pointer to a pointer of the information. This should do the trick: struct dirent namelist; /* this is where the info will really go */ /* it says to allocate space for a dirent */ struct dirent *namelist_p; /* this declares space for a ptr to a dirent */ struct dirent **namelist_p_p; /* and this a ptr to a ptr to a dirent */ /* the relationship amongst these is: */ /* namelist_p_p -> namelist_p -> namelist */ /* make the declared pointers really point to where we want */ namelist_p = &namelist; /* point to namelist */ namelist_p_p = &namelist_p; /* point to namelist_p */ /* the call would then look like: */ scandir("/bin", namelist_p_p, NULL, NULL); OR possibly, scandir("/bin", &namelist_p, NULL, NULL); OR MAYBE, but I don't think so, scandir("/bin", &&namelist, NULL, NULL); -------------------------------------------- I guess you get the idea from the above verbose example. I got trapped by this problem several times, and still do now and again. The trick is to always know what the pointers are pointing to and that you have allocated space for the data to actually reside. I hope this helps. Dave Marks Rome Laboratory marks@aivax.radc.af.mil