Click to See Complete Forum and Search --> : Usage of Utime() function -urgent


nivedita
February 20th, 2002, 10:42 PM
pls give me an example of utime funtion to set the file modification time.
when i used this with null parameter it does not change the file modification time to the current time

Igor Soukhov
February 21st, 2002, 12:37 AM
From MSDN:


/* UTIME.C: This program uses _utime to set the
* file-modification time to the current time.
*/

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/utime.h>

void main( void )
{
/* Show file time before and after. */
system( "dir utime.c" );
if( _utime( "utime.c", NULL ) == -1 )
perror( "_utime failed\n" );
else
printf( "File time modified\n" );
system( "dir utime.c" );
}





Output

Volume in drive C is ALDONS
Volume Serial Number is 0E17-1702

Directory of C:\dolphin\crt\code

05/03/94 10:00p 451 utime.c
1 File(s) 451 bytes
83,320,832 bytes free
Volume in drive C is ALDONS
Volume Serial Number is 0E17-1702

Directory of C:\dolphin\crt\code

05/03/94 10:00p 451 utime.c
1 File(s) 451 bytes
83,320,832 bytes free
File time modified


Please - rate answer if it helped you
It gives me inspiration when I see myself in the top list =)

Best regards,

-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com

Russian Software Developer Network http://rsdn.ru

nivedita
February 21st, 2002, 12:55 AM
Thanks a lot
it helped me :-)