January 23, 2004 Re: Appending char to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | Stephan Wienczny wrote: > > Another way would be to only copy if used as return value. > Exactly, copy on return. Of course the compiler could optimise that a bit. -- -Anderson: http://badmama.com.au/~anderson/ |
January 23, 2004 [bug?] Re: Appending char to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | Really non-obvious, thus i flag it a bug? for now.
-eye
Stephan Wienczny wrote:
> Hallo,
>
> what is the standard D way of appending a char to a char[]?
> I've go a function expecting a char[]. How do I convert a char to a
> char[] in a function call?
>
> void xyz(char[] abc);
> {
> char[] string = "My string";
> char c = '!';
> xyz(string ~ c);
> }
>
> Stephan
>
|
January 24, 2004 Re: Appending char to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | How about this ? void xyz(char[] abc) { printf("%.*s", abc); } void main() { char[] string = "My string"; char c = '!'; xyz(string ~ (&c)[0..1]); } YT |
January 25, 2004 Re: Appending char to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | Stephan Wienczny schrieb: [...] > The compiler should forbid to return static data as the result is undefined. Another way would be to only copy if used as return value. How does this agree with the docs: | It is an error to return the address of or a reference to a local | variable. So long. -- Fight Spam! Join EuroCAUCE: http://www.euro.cauce.org/ 2EA56D6D4DC41ABA311615946D3248A1 |
January 25, 2004 Re: Appending char to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Nowak | Manfred Nowak wrote: >Stephan Wienczny schrieb: > >[...] > > >>The compiler should forbid to return static data as the result is undefined. Another way would be to only copy if used as return >>value. >> >> > >How does this agree with the docs: > >| It is an error to return the address of or a reference to a local >| variable. > >So long. > > Well it doesn't cause an error message does it. -- -Anderson: http://badmama.com.au/~anderson/ |
Copyright © 1999-2021 by the D Language Foundation