Wednesday, 20 February 2013

Program:To implement in c the following unix commands using system calls 1.ls

/*

Program:To implement in c the following unix commands using  system calls
         1.ls       

*/
  #include
   #include
   #include
   #include
   #include
   main(int argc,char *argv[])
   {
           DIR *dp;
           struct dirent *p;
          dp=opendir(argv[1]);
          while((p=readdir(dp))!=NULL)
          {
                  printf("\n%s",p->d_name);
                  printf(" %d",p->d_ino);
          }
          closedir(dp);
 }


/*----------------------INPUT/OUTPUT-------------

mymv.c 23794493
f3.c 23794091
sam.sh 23790637
sample.sh 23790652
range.af 23790887
man 23790875
. 23789662
mycp.c 23794414
.bash_history 23794443
middle.sh 23790680
man.sh 23790242
.viminfo 23794532
ex2.txt 23792334
mansoor.txt 23790235
display.sh 23792459
delete.sh 23791674
.swp 23790432
copy 23790777
.bash_profile 23794529
copy.c 23794460
line.sh 23792285
ex1.txt 23792579
c 23790660-vi myls.c


------------------------------------------------------*/

2 comments: