Skip to content

Instantly share code, notes, and snippets.

@ABeltramo
Created October 6, 2014 12:08
Show Gist options
  • Save ABeltramo/7f96ad3a9f195ad746c0 to your computer and use it in GitHub Desktop.
Save ABeltramo/7f96ad3a9f195ad746c0 to your computer and use it in GitHub Desktop.
Duplica stringa
char *duplica(char *input) {
size_t len = strlen(input);
//Alloco un nuovo buffer
char *buffer = (char*) malloc(len+1);
if (buffer) {
memcpy(buffer, input, len);
buffer[len] = '\0'; //chiudo la stringa
}
return buffer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment