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

Adam D. Ruppe destructionator at gmail.com
Thu Feb 22 18:02:11 UTC 2018


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 `fromStringz` function 
in Phobos to convert it and copy it if you want to store it.

http://dpldocs.info/experimental-docs/std.string.fromStringz.html

import std.string;
string s = fromStringz(abc.ptr).idup; // the idup copies it out


More information about the Digitalmars-d-learn mailing list