Thread overview
Help anyone?
Sep 13, 2002
Andrew Edwards
Sep 13, 2002
Pavel Minayev
Sep 13, 2002
Andrew Edwards
September 13, 2002
the following code:

import stream;
import file;
int main (char[][] args)
{
   File file = new File;
   file.create("test.txt");
   int a = 0, b = 1;
   for (int i = 0; i < 1000; i++)
   {
      int c = a + b;
      file.write(c);
      a = b; b = c;
   }
   return 0;
}

generates the attached file.  Does this happen to anyone except me?

Thanks in advance,
Andrew

September 13, 2002
Andrew Edwards wrote:
> the following code:
> 
> import stream;
> import file;
> int main (char[][] args)
> {
>    File file = new File;
>    file.create("test.txt");
>    int a = 0, b = 1;
>    for (int i = 0; i < 1000; i++)
>    {
>       int c = a + b;
>       file.write(c);
>       a = b; b = c;
>    }
>    return 0;
> }
> 
> generates the attached file.  Does this happen to anyone except me?

Yes, it is supposed to work that way. Unlike C++ iostreams, Stream.write() saves data as binary, not as text.

If you nead to read/write text files, use Stream.printf() and Stream.scanf().

By the way, there is no need to import file.d in your program. stream.d would be enough.

September 13, 2002
"Pavel Minayev" <evilone@omen.ru> wrote in message news:alrsvt$gvj$1@digitaldaemon.com...

| By the way, there is no need to import file.d in your program. stream.d | would be enough.

That was my next question! Thank you very much!