1 #include<stdio.h>
2 #include<sys/types.h>
3 #include<dirent.h>
4 #include<unistd.h>
5
6 int main(int argc,char *argv[])
7 {
8 char path[1000];
9 DIR *dp;
10 int i;
11
12 struct dirent *pdirent;
13 if(argc!=2)
14 {
15 printf(“The number of argument is wrong”);
16 return 1;
17 }
18 if((dp=opendir(argv[1]))==NULL)
19 {
20 printf(“Opendir %s failed\n”,argv[1]);
21 return 2;
22 }
23
24 while(pdirent=readdir(dp))
25 {
26 printf("%s %ld\n",pdirent->d_name,pdirent->d_ino);
27
28 }
29 closedir(dp);
30 return 0;
31 }
~
编写简单程序,罗列目录下所有文件及其所对应的i节点编号。
最新推荐文章于 2023-08-24 21:23:21 发布