Thread overview | |||||
---|---|---|---|---|---|
|
November 20, 2010 BufferedFile.write | ||||
---|---|---|---|---|
| ||||
Hi, In D2: Stream file = new BufferedFile("sample.txt"); file.write("hello"); file.close(); Produces... src\gie2\main.d(11): Error: function std.stream.Stream.write called with argument types: ((string)) matches both: std.stream.Stream.write(const(char)[] s) and: std.stream.Stream.write(const(wchar)[] s) Do I have to do this? file.write(cast(string)"hello"); Seems ugly. KR T; |
November 20, 2010 Re: BufferedFile.write | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom | El 20/11/2010 02:52, Tom escribió:
> Hi,
>
> In D2:
>
> Stream file = new BufferedFile("sample.txt");
> file.write("hello");
> file.close();
>
> Produces...
>
> src\gie2\main.d(11): Error: function std.stream.Stream.write called with
> argument types:
> ((string))
> matches both:
> std.stream.Stream.write(const(char)[] s)
> and:
> std.stream.Stream.write(const(wchar)[] s)
>
> Do I have to do this?
>
> file.write(cast(string)"hello");
>
> Seems ugly.
>
> KR
> T;
Sorry, seems like I should have used writeString. Now it makes some sense.
|
November 20, 2010 Re: BufferedFile.write | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tom | "Tom" <tom@nospam.com> wrote in message news:ic7nq3$6i6$1@digitalmars.com... > Do I have to do this? > > file.write(cast(string)"hello"); You can set the type of a string literal using a suffix: "hello"c - string "hello"w - wstring "hello"d - dstring |
Copyright © 1999-2021 by the D Language Foundation