Skip to content

Instantly share code, notes, and snippets.

@kasramp

kasramp/ls.c Secret

Created August 3, 2020 19:18
Show Gist options
  • Save kasramp/cce95df1e5a6466cc084e70aa6d1e5d5 to your computer and use it in GitHub Desktop.
Save kasramp/cce95df1e5a6466cc084e70aa6d1e5d5 to your computer and use it in GitHub Desktop.
#include <dirent.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
DIR *dir;
struct dirent *de;
if (argc > 1)
dir = opendir(argv[1]); /*your directory*/
else
dir = opendir("."); /* Default: current path */
while (dir)
{
de = readdir(dir);
if (!de)
break;
printf("%s\n", de->d_name);
}
closedir(dir);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment