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...

write a program to display all the files from the current
directory which are created in particular month

Answer Posted / rakesh

#include<stdio.h>

#include<stddef.h>

#include<dirent.h>

#include<string.h>

#include<sys/types.h>

#include<sys/stat.h>

#include<time.h>

#include<stdlib.h>


int main(int argc,char *argv[])

{

char in[100],st[100],*ch,*ch1,c,buff[512];

DIR *dp;

int i;

struct dirent *ep;

struct stat sb;

char mon[100];

dp=opendir("./");

if(dp!=NULL)

{

while(ep=readdir(dp))

{

if(stat(ep->d_name,&sb)==-1)

{

perror("stat");


exit(EXIT_SUCCESS);

}

strcpy(mon,ctime(&sb.st_ctime));

ch=strtok(mon," ");

ch=strtok(NULL,",");

ch1=strtok(ch," ");


if((strcmp(ch1,argv[1]))==0)

{

printf("%s \t\t %s",ep->d_name,ctime(&sb.st_ctime));

}

}

(void)closedir(dp);

}
return 0;

}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I set the default rwx permission to all users on every file which is created in the current shell?

1413


Is shell script a programming language?

1011


What is the default shell of solaris?

1032


How to debug the problems encountered in the shell script/program?

1118


How to check if the previous command was run successfully?

1017


What does egrep mean?

952


how to get part of string variable with echo command only?

1006


What makes c shell a more preferable option than the bourne shell?

956


determine the output of the following command: echo ${new:-variable}

964


Write a command sequence to find all the files modified in less than 2 days and print the record count of each.

1489


What does the sh command do?

1067


What are the default permissions of a file when it is created?

999


What is path variable bash?

1025


Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.

2650


Why do we write bin bash in shell scripts?

998