Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 18:02:11 UTC, Adam D. Ruppe wrote: You don't strip that at all, the function writes a zero-terminated string to the buffer. Thank you very much ! I forgot it.

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 22 February 2018 at 17:44:53 UTC, FrankLike wrote: SHGetSpecialFolderPath(NULL,cast(char*)Path.ptr,CSIDL_DESKTOP,0); You don't strip that at all, the function writes a zero-terminated string to the buffer. So either: use the pointer as-is to other C functions, or call the

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 16:59:40 UTC, Adam D. Ruppe wrote: On Thursday, 22 February 2018 at 16:55:14 UTC, FrankLike wrote: char[100] abc ="aabc"; auto abcaa = ((abc).dup).stripRight; try: auto abcaa = stripRight(abc[]) Now,I want to get the result: char[100] Path;

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 17:08:14 UTC, FrankLike wrote: On Thursday, 22 February 2018 at 16:59:40 UTC, Adam D. Ruppe wrote: On Thursday, 22 February 2018 at 16:55:14 UTC, FrankLike wrote: It is simply that these functions require a slice so it can resize it and you can't resize a

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
On Thursday, 22 February 2018 at 16:59:40 UTC, Adam D. Ruppe wrote: On Thursday, 22 February 2018 at 16:55:14 UTC, FrankLike wrote: It is simply that these functions require a slice so it can resize it and you can't resize a static array. char[100] abc ="aabc"; string aa =

Re: How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 22 February 2018 at 16:55:14 UTC, FrankLike wrote: char[100] abc ="aabc"; auto abcaa = ((abc).dup).stripRight; try: auto abcaa = stripRight(abc[]) just make sure you do NOT return that abcaa from the function or store it in an object. It still refers to the static array

How to use strip or stripRight on char[len] ? Thanks.

2018-02-22 Thread FrankLike via Digitalmars-d-learn
Hi,everyone, How to use strip or stripRight on char[len]? For example: string abcs ="aabc"; auto abcsaa = abcs.stripRight; writeln(abcsaa); writeln("---abcsaa--stripRight ok "); char[100] abc ="aabc"; auto abcaa = ((abc).dup).stripRight; writeln(abcaa); writeln("stripRight