English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to give the file I open the current date in it's name. I allready insert some parameters into the file's name with sprintf command. example:

char filename1[64];
sprintf(filename1,"The_file_name_%g.dat",parameter1);

but how do I get it to write the date(preferebly 4 digits)?

2006-11-15 22:57:19 · 3 answers · asked by Ilham Aliyev 2 in Computers & Internet Programming & Design

I don't use windows, but Linux

2006-11-16 01:49:38 · update #1

3 answers

you can do that using time.h file

includ time.h in ur cpp file

check this reference for time.h
http://www.cplusplus.com/ref/ctime/localtime.html

thanx

2006-11-15 23:48:40 · answer #1 · answered by Inflame 2 · 0 0

sorry i dont know about c++ but why dont you do something like this in the shell script

field =date
filename=$filename_${field}

this will append the date with the filename you created with c++

hope it helps

2006-11-16 11:37:06 · answer #2 · answered by life goes on... 2 · 0 0

You can use SYSTEMTIME if you want to get at each time attribute...

SYSTEMTIME st;
GetSystemTime(&st);

Then you can access it's members:
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;

i.e. st.wHour ...

You must include to use it

2006-11-16 09:32:28 · answer #3 · answered by Josh Falter 3 · 0 0

fedest.com, questions and answers