Project/Real_code/book/ch06/ch06-sortdir.c
int
process(const char *dir)
{
	DIR *dp;
	struct dirent **entries;
	int nents, i;

	nents = scandir(dir, & entries, nodots, alphasort);
	if (nents < 0) {
		fprintf(stderr, "%s: scandir failed: %s\n", myname,
				strerror(errno));
		return 1;
	}

	for (i = 0; i < nents; i++) {
		printf("%8ld %s\n", entries[i]->d_ino, entries[i]->d_name);
		free(entries[i]);
	}

	free(entries);

	return 0;
}
/*
 * process --- do something with the directory, in this case,
 *             print inode/name pairs on standard output.
 *             Return 0 if all OK, 1 otherwise.
 */
do something with the directory, in this case,
print inode/name pairs on standard output.
Return 0 if all OK, 1 otherwise.
do something with the directory in this case print inode / name pairs on standard output . Return 0 if all OK 1 otherwise .
int
process(const char *dir)
{
	DIR *dp;
	struct dirent **entries;
	int nents, i;
	nents = scandir(dir, & entries, nodots, alphasort);
	if (nents < 0) {
		fprintf(stderr, "%s: scandir failed: %s\n", myname,
				strerror(errno));
		return 1;
	}
	for (i = 0; i < nents; i++) {
		printf("%8ld %s\n", entries[i]->d_ino, entries[i]->d_name);
		free(entries[i]);
	}
	free(entries);
	return 0;
}
int process ( const char * dir ) { DIR * dp ; struct dirent * * entries ; int nents , i ; nents = scandir ( dir , & entries , nodots , alphasort ) ; if ( nents < 0 ) { fprintf ( stderr , " \n " , myname , strerror ( errno ) ) ; return 1 ; } for ( i = 0 ; i < nents ; i ++ ) { printf ( " \n " , entries [ i ] -> d_ino , entries [ i ] -> d_name ) ; free ( entries [ i ] ) ; } free ( entries ) ; return 0 ; }
process --- do something with the directory, in this case,
             print inode/name pairs on standard output.
process --- do something with the directory in this case print inode / name pairs on standard output .