RE: [Dev-C++] Time stamping an output file.
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ya...> - 2002-02-25 19:18:53
|
I am sorry obviously i did not understand the question. I thought you
wanted to manipulate the date/time stamp of the files, but you wanted to
put a string to the filename. You can use the functions ctime() and
time() of time.h in the style:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main(void)
{
char filename[]="some filename - ";
time_t tp=time(NULL);
char *s=ctime(&tp);
char *newname=malloc(strlen(filename)+strlen(s)+1);
if(!newname)
return EXIT_FAILURE;
strcpy(newname, filename);
strcat(newname, s);
puts(newname);
return 0;
}
Keep in mind that this operation is portable, that is it works
everywhere.
Ioannis
* Ioannis Vranos
* Programming pages: <http://www.noicys.d2g.com/>
http://www.noicys.d2g.com
* Alternative URL: <http://run.to/noicys> http://run.to/noicys
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Ioannis
Vranos
Sent: Monday, February 25, 2002 8:42 PM
To: Dev-C++
Subject: RE: [Dev-C++] Time stamping an output file.
You can do it with win32 api:
Syntax
#include <io.h>
int getftime(int handle, struct ftime *ftimep);
int setftime(int handle, struct ftime *ftimep);
[ Useless things ]
|