I am originally a Java programmer and I have a deep love of the syntax, especially regarding the String
object. With C++, I have tried to recreate the toUpperCase()
method that Java has. The only problem is that it always returns a String
object that has an empty/NULL char array.
String String::toUpperCase()
{
char *a = new char[this->length + 1];
memset(a, 0, this->capacity + 1);
memcpy(a, this->characters, this->length);
for (int i = 0; i < strlen(this->characters); i++)
{
toupper(a[i]);
}
return *new String(a);
}