Here is the code I wrote. It makes a const char* to uppercase. First argument is a pointer to a const char* and the second argument is a temp place holder which is allocated in the heap.
#include <cctype> #include <cstring> #include <iostream> void c_strtoupp(const char** c_str, char* _temp) { std::strcpy(_temp, *c_str); for (unsigned int i = 0; i < std::strlen(*c_str) + 1; i++) _temp[i] = static_cast<char>(std::toupper(_temp[i])); *c_str = _temp; } int main() { const char** s = new const char*("alexander"); char* _t = new char[std::strlen(*s) + 1]; c_strtoupp(s, _t); std::cout << *s << '\n'; delete s; s = nullptr; delete[] _t; _t = nullptr; //std::cin.get(); // to pause console return 0; }
std::stringinsteads?