#include "apue.h"
#include <dirent.h>
int main(int argc, char const *argv[])
{
DIR *dp;
struct dirent *dirp;
if (argc != 2)
err_quit("usage: ls diretory_name");
if ((dp = opendir(argv[1])) == NULL)
err_quit("can't open %s", argv[1]);
while((dirp=readdir(dp)) != NULL)
printf("%s\n",dirp->d_name);
closedir(dp);
exit(0);
}
http://www.chenqing.org/2013/08/mac-os-10-8-apue-make.html
转载于:https://my.oschina.net/u/224770/blog/172555