DMD2 语言错误解决:cannot implicitly convert expression 'Hello, world!' of type string to ulong
import std.string; import core.stdc.stdio;
extern(C) { void main() { ulong ptr = cast(ulong) new string('Hello, world!'); // 使用cast将字符串的指针转换为ulong类型 printf('%s',cast(char*)ptr); (cast(string*)ptr).destroy(); // 将指针转回string类型并销毁字符串 } }
原文地址: https://www.cveoy.top/t/topic/n0VU 著作权归作者所有。请勿转载和采集!