Help with reading and writing to a file
Michel Bardiaux
mbardiaux at peaktime.be
Fri Jun 11 18:55:57 CEST 2004
Steve Torri wrote:
> On Fri, Jun 11, 2004 at 06:16:38PM +0200, Michel Bardiaux wrote:
>
>>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 << ""
>>
>
>
> How does one post a "dump"? Our definition of words I think may be
> different.
>
> In regards to the line you gave it does not work. I will provide a
> better answer in the way you want (e.g. a dump of the binary file)
> when I receive your answer to my question.
>
> Stephen
On Unix:
Command: od -bc mpz_test.dat
Output:
0000000 001 000 000 000 350 003 000 000 001 000 000 000 065 060 060 060
001 \0 \0 \0 350 003 \0 \0 001 \0 \0 \0 5 0 0 0
0000020 071 060 060 060 001 000 000 000
9 0 0 0 001 \0 \0 \0
0000030
On Windows I dont know if one can save the window of a GUIed hexdump
utility as text.
And, yes, I gave a bad line. << "" *cant* work because it actually does
nothing! Sorry. Try
m_file_handle << val << "\n" (or << std:endl, should be equivalent)
What does the dump look like now? Is there a non-digit byte between the
strings 5000 and 9000 ?
You asked why the extra <<"\n" is not part of the << operator. Well,
that was standard C output and became standard C++ output:
stream << "12" << "34" produces 1234 and so does
stream << "12" ; stream << "34"
--
Michel Bardiaux
Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
Tel : +32 2 790.29.41
More information about the gmp-discuss
mailing list