Write a command line program to accept number say N1. Display all files from the current directory, whose size is greater than N1.
#include
#include
#include
#include
#include
#include
char path[50];
int main(int argc, char* argv[])
{
int size;
// to get the Current Directory Path Used This System Call..!!
getcwd(path,50);
printf("Current Directory Path Is:%s\n",path);
DIR *mydir;
struct dirent *myfile;
struct stat mystat;
mydir = opendir(path);
while((myfile = readdir(mydir)) != NULL)
{
stat(myfile->d_name, &mystat);
size = atoi(argv[1]);
if(mystat.st_size > size)
{
printf("%d",mystat.st_size);
printf(" %s\n", myfile->d_name);
}
}
closedir(mydir);
}
#include
#include
#include
#include
#include
char path[50];
int main(int argc, char* argv[])
{
int size;
// to get the Current Directory Path Used This System Call..!!
getcwd(path,50);
printf("Current Directory Path Is:%s\n",path);
DIR *mydir;
struct dirent *myfile;
struct stat mystat;
mydir = opendir(path);
while((myfile = readdir(mydir)) != NULL)
{
stat(myfile->d_name, &mystat);
size = atoi(argv[1]);
if(mystat.st_size > size)
{
printf("%d",mystat.st_size);
printf(" %s\n", myfile->d_name);
}
}
closedir(mydir);
}
Comments
Post a Comment