March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
|
|
@ -0,0 +1,14 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern bool query(char *data, size_t *length);
|
||||
|
||||
int main() {
|
||||
char buffer[1024];
|
||||
size_t size = sizeof(buffer);
|
||||
|
||||
if (query(buffer, &size))
|
||||
printf("%.*s\n", size, buffer);
|
||||
else
|
||||
puts("The call to query has failed.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue