在 Ubuntu(Linux)里,没有叫 copendir 的标准函数或命令。你可能是想说下面几种情况之一:
opendir()(很多人把 opendir 误写成 copendir)
#include <dirent.h>
#include <stdio.h>
int main() {
DIR *dir = opendir("/home/user");
if (dir == NULL) {
perror("opendir");
return 1;
}
// 使用目录...
closedir(dir);
return 0;
}
gcc test.c -o test
./test
cd /path/to/directory
xdg-open /path/to/directory
或
nautilus /path/to/directory
cp -r source_dir target_dir
struct dirent *entry;
while ((entry = readdir(dir)) != NULL) {
printf("%s\n", entry->d_name);
}
如果你能补充一下:
我可以给你更精确的示例。