Dynamic allocation
n#include <cstring>
n
n// Leaves us with a dangling pointer, also wastes space
nchar* dup_string(char* s) {
n const int max_buf = 1024;
n char buf[max_buf];
n strcpy(buf, s);
n return buf;
n}
n
n// Using dynamic allocation we're okay
nchar* dup_string(char* s) {
n int cnt = strlen(s) + 1;
n char* new_string = new char[cnt];
n return new_string;
n}