Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I search for a file with the date inside the filename? 1

Status
Not open for further replies.

jdouthit

IS-IT--Management
Jun 15, 2004
14
0
0
US
I'm trying to check to see if a file exists with a filename something like dkout-YYYY-mm-dd.txt where the YYYY would be the year in 4 digits, mm the month in two digits, and dd be the day in two digits. I really don't have a clue as to how to format a file with a date. This program will run everyday so it will need to check for the current date inside the filename each day. Can anybody help me with this? Thanks in advance.
 
i use this to get the system time and write it into a char string:

Code:
  struct tm *timeptr;
  time_t clock;

  if ( time ( &clock ) != (time_t)-1 )
  {
    if ( timeptr = localtime ( &clock ) )
    {
      strftime ( text, 249, " %d/%m/%Y %H:%M:%S", timeptr );
    }
  }
 
What does the "text" stand for in the strftime function?
 
ah forgot to put that in

It is simply a character string i.e.

char text[249];

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top