Need a little example of scandir()

Kartik Subbarao subbarao at phoenix.Princeton.EDU
Thu May 23 01:25:42 AEST 1991


>#include <sys/types.h>
>#include <sys/dir.h>
>
>myroutine()
>{
>	int numfiles,loop;
>	struct direct *namelist; 

should be struct direct **namelist; 

>
>	if ((numfiles = scandir(".", namelist, NULL, NULL)) == -1) {

should be scandir(".", &namelist, NULL, NULL);
...
etc

>	  perror("myprogram");
>	  exit(1);
>	}
>
>	for(loop = 0; loop < numfiles; ++loop)
>	  printf("Name -> <%s>\n",namelist[loop].d_name);

should be namelist[loop]->d_name

>}


As the man page says. It's a weird man page.


		-Kartik


--
internet% ypwhich

subbarao at phoenix.Princeton.EDU -| Internet
kartik at silvertone.Princeton.EDU (NeXT mail)  
SUBBARAO at PUCC.BITNET			          - Bitnet



More information about the Comp.unix.programmer mailing list