Simulation of Unix Commands - ls



SIMULATION OF UNIX COMMANDS

Programs
// 1. ls command
#include<stdio.h>                                     
#include<fcntl.h>
#include<sys/stat.h>                       
#include<dirent.h>

int main(int argc,char *argv[])
{
DIR *dp;
struct dirent *sd;
dp=opendir(argv[1]);

while((sd=readdir(dp))!=NULL)
printf("%s\t",sd->d_name);

closedir(dp);
}



No comments:

Post a Comment

Don't be a silent reader...
Leave your comments...

Anu