Help with reading and writing to a file
mbardiaux at peaktime.be
Fri Jun 11 18:16:38 CEST 2004
Steve Torri wrote:
> On Fri, Jun 11, 2004 at 10:19:39AM +0200, Michel Bardiaux wrote:
>>Steve Torri wrote:
>>>So the Group_Set's variables m_speed = 5000 and m_time = 9000. So when
>>>this is written to a file I should see a 5000 and a 9000 in the file
>>>if I read it with hexedit.
>>I suggest you post the hex dump of the file.
>>>The reader which reads the values back from
>>>the file uses the macros I described above. When I print out the
>>>values that I have read from the file I get the following values:
>>> m_speed = 50009000
>>> m_time = 0
> The binary file is attached. There are three uint32_t variables
> printed before the two mpf_class followed by a uint32_t variable.
If you had posted the *dump* you would have looked at it and seen that
there is nothing between the 2 strings. So, when you read back in, the
runtime follows the normal rules: when reading a number, it stops when
it sees a non-digit. There are 8 consecutive digits so of course they
are read in as *one* number. You get zero for the 2nd one, you should
have checked for EOF.
My C++ is basic at best but I thing what you need is:
m_file_handle << val << ""
Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
Tel : +32 2 790.29.41
More information about the gmp-discuss