manipulate date on files

This is a discussion on manipulate date on files within the C Programming forums, part of the General Programming Boards category; I have a problem how do i write back the c_file.time_write to the files ? Code: if( (hFile = _findfirst( ...

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    12

    manipulate date on files

    I have a problem how do i write back the c_file.time_write to the files ?

    Code:
     if( (hFile = _findfirst( "*.bmp", &c_file )) == -1L )
           printf( "No *. bmp files in current directory!\n" );
       else
       {
    
               c_file.time_write = rand(lDateTime);
       }
    
    while( _findnext( hFile, &c_file ) == 0 )
                {
                      c_file.time_write = rand(lDateTime);
                 }

    Basically i need to change the dates to random values if there is a way please tell me anyone

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    Well we could spend some time guessing your OS and compiler...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    12
    Sorry salem its Windows and my compiler is Dev C++

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by Salem View Post
    Well we could spend some time guessing your OS and compiler...
    findfirst() is a Windows function, with legacy dating back to the days of MS-DOS.

  5. #5
    Registered User
    Join Date
    Mar 2007
    Posts
    12
    Do u have any idea how can i set the dates to what ever i like ? i dont have to use thoes functions

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    Which is in itself ironic, since they seem to be using a win32 compiler on a win32 OS.

    http://faq.cprogramming.com/cgi-bin/...&id=1044780608
    Read xtree.cpp at the end.
    Then look for related API calls on msdn.microsoft.com until you find the one for changing attributes.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Mar 2007
    Posts
    12
    its not win32 but a console

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    It's still the win32 API though.
    Did you read the FAQ?
    Did you see #include <windows.h> in the xtree.cpp example?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error opening files in a different dir
    By Ozzie in forum C++ Programming
    Replies: 3
    Last Post: 10-09-2008, 06:55 AM
  2. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 10:46 AM
  3. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 08:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 03:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21