Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

c program to implement the unix or linux command to
implement
ls -l >output.txt

Answer Posted / gunjan

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>

int main(int argc, char* argv[])
{
DIR *mydir;
struct dirent *myfile;
struct stat mystat;

mydir = opendir(argv[1]);
while((myfile = readdir(mydir)) != NULL)
{
stat(myfile->d_name, &mystat);
printf("%d",mystat.st_size);
printf(" %s
", myfile->d_name);
}
closedir(mydir);
}

Is This Answer Correct ?    3 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain c program to implement the unix or linux command to implement ls -l >output.txt?

792


How to protect a process from others to kill?

906


What is the fork() system call?

895


Explain the unmount system calls?

902


What is the first process created by the kernel in unix?

825


What is the difference between command and utility in unix?

884


Name the command which is used to execute system calls from exe?

895


Explain the mount and unmount system calls?

982


Explain the mount system calls?

895


The very first process created by the kernel in unix is?

812


What are the possible return values of kill() system call?

805


Tell me how to protect a process from others to kill?

790


Explain the difference between command and utility in unix?

902