Created
October 6, 2014 12:08
-
-
Save ABeltramo/7f96ad3a9f195ad746c0 to your computer and use it in GitHub Desktop.
Duplica stringa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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