Unix環境高度プログラミング1
1090 ワード
、 /etc/passwd , , ,7 、 、 ID、 ID、 、 、shell
、 bash
、 ls
#include
#include
#include
using namespace std;
int main( int argc, char* argv[] )
{
DIR *dp;
struct dirent *dirp;
if(argc != 2)
{
cout << "a single argument (the directory name) is required" << endl;
return 0;
}
if( (dp=opendir(argv[1])) == NULL)
{
cout << "can't open " << argv[1] << endl;
return 0;
}
while( (dirp = readdir(dp)) != NULL)
{
cout << dirp->d_name << endl;
}
closedir(dp);
return 0;
}
-> り9999 30