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

What is a batch file used for?

1026


What is the use of a shebang line?

1111


What is bash used for?

962


How does shell scripting work?

1052


Why are shell scripts used?

1022


What is the first line in every perl script called?

976


Is powershell a bash?

1014


Explain about "s" permission bit in a file?

994


What is meant by $1 in shell script?

904


What is shell geeksforgeeks?

1028


Devise a script that takes file name as arguement(which must present in the current directory)and locates from your home directory tree all thpath names of its links.Then mail the list to self.

2143


Is shell script a programming language?

976


What is shift command in shell script?

963


c program to display the information of given file similar to givan by the unix or linux command ls -l

2148


What are types of shells?

963