RosettaCodeData/Task/Use-another-language-to-call-a-function/D/use-another-language-to-call-a-function-1.d
2023-07-01 13:44:08 -04:00

14 lines
342 B
D

import core.stdc.string;
extern(C) bool query(char *data, size_t *length) pure nothrow {
immutable text = "Here am I";
if (*length < text.length) {
*length = 0; // Also clears length.
return false;
} else {
memcpy(data, text.ptr, text.length);
*length = text.length;
return true;
}
}