473,410 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

time_create, time_access, etc...

I've been working on a directory listing program and I want to add
things like time_create to it...

\\-------------------------------------
#include <io.h>
#include <stdio.h>
#include <string.h>
int i = 0;
int m=0;
char filelist[100][100];

struct _finddata_t fd;
int main() {
long fh = _findfirst("*.*", &fd);
if (fh != -1) {
do {
if (fd.attrib & _A_SUBDIR);
else sprintf(filelist[i++], "%i", fd.time_create);

}
while (_findnext(fh, &fd) == 0);

m=i;
for (i=0; i < m; i++) printf("%s\n", filelist[i]);
system("pause");
_findclose(fh);
}
return 0;
}
//---------------------

This lists out the dates and times of all the files in a certain
format, which I cannot convert.
It took me a while to work out a program in gcc. If you can help me
with any examples, it would be appreciated.

Nov 26 '05 #1
3 2396
"re*******@yahoo.com" <re*******@yahoo.com> writes:
I've been working on a directory listing program and I want to add
things like time_create to it...
[...]
This lists out the dates and times of all the files in a certain
format, which I cannot convert.


The program you included is Windows or MS-DOS specific, so you'd
be better off asking in a newsgroup that focuses on one of those
operating systems.
--
"C has its problems, but a language designed from scratch would have some too,
and we know C's problems."
--Bjarne Stroustrup
Nov 26 '05 #2
re*******@yahoo.com wrote:
I've been working on a directory listing program and I want to add
things like time_create to it...

\\-------------------------------------
#include <io.h>
Non-standard header, we only deal with standard C here, not
implementation specific extensions.
#include <stdio.h>
#include <string.h>
int i = 0;
int m=0;
Why are these global variables? I can see no good reason, so they should
have been declared inside main. If there is a good reason for them to be
globals then you should chose meaningful longer names.
char filelist[100][100];
Why 100 by 100? I see nothing below to stop you from having more than
100 files, and I doubt that it is possible for the string representation
of an int to be anywhere near 99 characters long.
struct _finddata_t fd;
_finddata_t is non-standard.
int main() {
If you are not using the parameters to main it is better to be explicit.
int main(void) {
long fh = _findfirst("*.*", &fd);

if (fh != -1) {

do {

if (fd.attrib & _A_SUBDIR);

else sprintf(filelist[i++], "%i", fd.time_create);
If the directory has more than 100 entries this is going to go bang.
}
while (_findnext(fh, &fd) == 0);

m=i;
for (i=0; i < m; i++) printf("%s\n", filelist[i]);
system("pause");
_findclose(fh);
}
return 0;
}

//---------------------

This lists out the dates and times of all the files in a certain
format, which I cannot convert.
It took me a while to work out a program in gcc. If you can help me
with any examples, it would be appreciated.


Standard C does not know anything about directories or the _finddata_t
struct. I suggest you try asking in a group dedicated to whatever OS you
are using.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 26 '05 #3
"re*******@yahoo.com" <re*******@yahoo.com> wrote:

# else sprintf(filelist[i++], "%i", fd.time_create);

# This lists out the dates and times of all the files in a certain

If these date-times are in the same form as what time()
returns (you'll need to check the system specific documentation),
you can use localtime, strftime, and related functions
to convert to the gregorian calendar for output.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
So....that would make Bethany part black?
Nov 27 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Juris Krumins | last post by:
Couple a weeks ago (19.08.03 Subject: Temporaty tables) I've posted message with question about errors I'm getting while using create temporaty table command. So I'm start digging in src code as...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.