我必須創建一個包含在特定目錄內的文件的列表,我已經完成了下面的代碼(更大程序的一部分),但是我希望我的程序忽略可能包含在目錄中的任何可能的文件夾。只獲取包含在c/Ubuntu目錄中的文件
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
int main()
{
DIR *dirptr;
struct dirent *entry;
dirptr = opendir ("synchedFolder");
if (dirptr != NULL)
{
while (entry = readdir (dirptr))
{
if(strcmp(entry->d_name,"..")!=0 && strcmp(entry->d_name,".")!=0)
puts (entry->d_name);
}
(void) closedir (dirptr);
}
else
perror ("ERROR opening directory");
}
你不能使用shell腳本? – Makis