#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
char *
my_strupr(char *s)
{
char *start = s;
for (; *s; ++s)
*s = std::toupper(*s);
return start;
}
char *
my_strdup(char const *src)
{
char *dst = new char[ std::strlen(src) + 1 ];
std::strcpy(dst, src);
return dst;
}
char *
strupr_copy(char const *s)
{
return my_strupr(my_strdup(s));
}
int
main()
{
char const *src = "Hello, World!";
char * dst = strupr_copy(src);
std::cout << src << " --> " << dst << '\n';
delete dst;
}
I2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPGNzdGRsaWI+CiNpbmNsdWRlIDxjc3RyaW5nPgojaW5jbHVkZSA8aW9zdHJlYW0+CgpjaGFyICoKbXlfc3RydXByKGNoYXIgKnMpCnsKICBjaGFyICpzdGFydCA9IHM7CiAgZm9yICg7ICpzOyArK3MpCiAgICAqcyA9IHN0ZDo6dG91cHBlcigqcyk7CiAgcmV0dXJuIHN0YXJ0Owp9CgpjaGFyICoKbXlfc3RyZHVwKGNoYXIgY29uc3QgKnNyYykKewogIGNoYXIgKmRzdCA9IG5ldyBjaGFyWyBzdGQ6OnN0cmxlbihzcmMpICsgMSBdOwogIHN0ZDo6c3RyY3B5KGRzdCwgc3JjKTsKICByZXR1cm4gZHN0Owp9CgpjaGFyICoKc3RydXByX2NvcHkoY2hhciBjb25zdCAqcykKewogIHJldHVybiBteV9zdHJ1cHIobXlfc3RyZHVwKHMpKTsKfQoKaW50Cm1haW4oKQp7CiAgY2hhciBjb25zdCAqc3JjID0gIkhlbGxvLCBXb3JsZCEiOwogIGNoYXIgKiAgICAgIGRzdCA9IHN0cnVwcl9jb3B5KHNyYyk7CiAgc3RkOjpjb3V0IDw8IHNyYyA8PCAiIC0tPiAiIDw8IGRzdCA8PCAnXG4nOwogIGRlbGV0ZSBkc3Q7Cn0K