Board index » cppbuilder » retrieving date from file using tfilestream???

retrieving date from file using tfilestream???


2005-12-20 12:13:58 AM
cppbuilder17
hello friends,
can't retrieve date stored in file using tfilestream.tfilestream is used for both reading and writing onto files.
writing is done as " temp->write((char *)ext, sizeof(ext))" (sorry for not using case sensitivity...)
where ext is defined as class.
the date mamber of class is "char date[15]" and "td" is tdatetime pointer.
used : "strcpy(date,td->CurrentDate().datestring().c_str())"
every other class members are easily retrievable...but not date...
is there any other way to store and retrieve from files....plz do help....
 
 

Re:retrieving date from file using tfilestream???

On 19 Dec 2005 09:13:58 -0700, DILIP K wrote:
Quote
the date mamber of class is "char date[15]" and "td" is tdatetime pointer.
Please show the exact code.
Also, does the class/struct look ok in the de{*word*81}?
--
liz
 

Re:retrieving date from file using tfilestream???

"DILIP K" < XXXX@XXXXX.COM >wrote in message
Quote
writing is done as " temp->write((char *)ext,
sizeof(ext))"
where ext is defined as class.
You canot write classes like that. That is very dangerous and error-prone.
Quote
the date mamber of class is "char date[15]" and "td" is
tdatetime pointer.
used : "strcpy(date,td->CurrentDate().datestring().c_str())"
That is also dangerous and error-prone. You have set asside only 15
characters to hold the data, but the string returned by the DateString()
method can potentially returns a lot more characters than 15, depending on
your machine's locale settings.
Gambit
 

{smallsort}

Re:retrieving date from file using tfilestream???

On Mon, 19 Dec 2005 11:14:24 -0800, Remy Lebeau (TeamB) wrote:
Quote
You canot write classes like that. That is very dangerous and error-prone.
In this case it looks like it may be do-able, as the OP's class
consists of char arrays, nonetheless, I agree, this ain't the best
way.
--
liz