September 11, 2009 Basic file i/o | ||||
---|---|---|---|---|
| ||||
What is the simplest way of using a file? There are two 'File's in Phobos and they conflict: 1) struct File in std.stdio 2) class File in std.stream The one in std.stream.File is definitely what I want to use. What to do? Prefer using full names in D as in std.stream.File? Perhaps std.stdio is too low-level and too C-like, and I should not use it anyway? Should I be using std.cstream instead, as it defines din and dout? Thank you, Ali |
September 11, 2009 Re: Basic file i/o | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Cehreli | Ali Cehreli wrote: > What is the simplest way of using a file? > > There are two 'File's in Phobos and they conflict: > > 1) struct File in std.stdio > 2) class File in std.stream That's crazy. > The one in std.stream.File is definitely what I want to use. What to do? Import std.stream, create a File object for each file you want to read or write, and use its methods. > Prefer using full names in D as in std.stream.File? You can put in your own module alias std.stream.File File; which'll mean that, whenever an unqualified File is used in the module where the declaration is placed, it means that File. > Perhaps std.stdio is too low-level and too C-like, and I should not use it anyway? It's good for simple console I/O (indeed, it's where you get writef), but I guess not much else. > Should I be using std.cstream instead, as it defines din and dout? You could indeed. I sometimes use din/dout myself. Other times I use the console I/O in my utility library http://pr.stewartsplace.org.uk/d/sutil/ HTH Stewart. |
Copyright © 1999-2021 by the D Language Foundation