Thread overview | |||||
---|---|---|---|---|---|
|
September 13, 2002 Help anyone? | ||||
---|---|---|---|---|
| ||||
Attachments: | 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 Re: Help anyone? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Edwards | 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 Re: Help anyone? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "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! |
Copyright © 1999-2021 by the D Language Foundation