get current time and convert it to string

Abby (J.P.) the.ueabraham at laposte.net
Wed Apr 26 05:43:18 PDT 2006


Hello,
I want to get current time and put it into a string, I tried this :


int* the_time;
std.c.time.time(the_time);

char* str_time_ptr;
str_time_ptr = std.c.time.ctime(the_time);

char[] anwser = "Current time is: " ~ *str_time_ptr;


But it does only concatenate the first letter of the array return by 
ctime. I looked for C examples, but they all use printf:
time_t rawtime;
time ( &rawtime );
printf ( "Current date and time are: %s", ctime (&rawtime) );

In my case I can't use printf, because char[] anwser has to be sent on a 
socket and printed to the screen. Do you have any solution (I'm quite 
bad at pointers, I must have missed something) ?

--
Abby.



More information about the Digitalmars-d-learn mailing list