Call a foreign-language function: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 880: | Line 880: | ||
BeginCFunction |
BeginCFunction |
||
char *strdup(const char *src) { |
char *strdup(const char *src) { |
||
char *dst = malloc(strlen (src) + 1); // Space for length plus |
char *dst = malloc(strlen (src) + 1); // Space for length plus null |
||
if (dst == NULL) return NULL; // No memory |
if (dst == NULL) return NULL; // No memory |
||
strcpy(dst, src); // Copy the characters |
strcpy(dst, src); // Copy the characters |
||
Line 897: | Line 897: | ||
Hello, World! |
Hello, World! |
||
</pre> |
</pre> |
||
=={{header|Go}}== |
=={{header|Go}}== |