1 2 3 4 5 6 7 8 9 10 11 12
//en.cppreference.com/w/c/string/byte/strdup.html #include <string.h> #include <stdio.h> #include <stdlib.h> int main(void) { const char *s1 = "Duplicate me!"; char *s2 = strdup(s1); printf("s2 = \"%s\"\n", s2); free(s2); }