Create Linux ls command C Program – Write a C program under Windows Operating System to create or simulate linux ls command.
Program code
#include<stdio.h> #include<dirent.h> int main(int argc, char **argv) { DIR *dp; struct dirent *link; dp=opendir(argv[1]); printf("\n contents of the directory %s are \n", argv[1]); while((link=readdir(dp))!=0) printf("%s\n",link->d_name); closedir(dp); }
Output
contents of the directory programms are . .. arrayio.c arraymaxpointer.cpp arraysumpointer.cpp -------------------------------- Process exited after 2.519 seconds with return value 0 Press any key to continue . . .
You may also like OS Lab Practicals:
- Using Linux System Calls Program Operating Systems Lab
- SJF Scheduling Algorithm Program Operating System LAB
- FCFS Scheduling Algorithm Program in C++