Roger Alcindor
asked on
Embarcadero C++ Builder XE2 TDateTime
In "the good old days" before VCL Unicode Strings, it was a simple matter to produce an array or characters from a TDateTime formatted in a specific way as follows:
char buff[50];
TDateTime d = d.CurrentDateTime();
memset buff(0,50,0);
sprint(buff,"%s",d.FormatS tring("dd/ mm/yy hh:nn;ss").c_str());
// buff now has the required data ready to send over a serial port or write to a file
With Embarcadero C++ Builder XE2 and later, how can this be coded ?
char buff[50];
TDateTime d = d.CurrentDateTime();
memset buff(0,50,0);
sprint(buff,"%s",d.FormatS
// buff now has the required data ready to send over a serial port or write to a file
With Embarcadero C++ Builder XE2 and later, how can this be coded ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Sara, the following line that I used to populate the buffer was
BytesToRaw(strDtTm.BytesOf (),buff,st rDtTm.Leng th());
BytesToRaw(strDtTm.BytesOf
BytesToRaw(strDtTm.BytesOf(),buff,st rDtTm.Leng th());
you may check the length argument. normally it is the size of the output buffer (in bytes) rather than the length of the input string in characters. since you have Unicode String, the size of a character is 2 bytes.
Sara
ASKER
Sorry, I thought that I had closed the question and assigned points.
ASKER
I wish to award point to sarabande
thanks, for correction as requested by the author.
Sara
Sara
Open in new window
...and send send_buff instead of buff itself...