[Solved] C++ How to fill a char* array of strings with new values using c_str() on top of old ones [duplicate]


I try to copy the string into the array of string literals

What you are trying to do isn’t legal C++. char* MapIds[5000] = ... should be const char* MapIds[5000] = ... and trying to overwrite anything in that array makes your program have undefined behavior.

I try to stay away from std::string and instead use char*’s because std::string is slow [to compile] with huge initialized list

Make a std::vector<std::string> (or std::array) that you put in one .cpp file by itself and make a header with an extern declaration. Only if you need to update that vector will you notice the extra time it takes to compile it.

solved C++ How to fill a char* array of strings with new values using c_str() on top of old ones [duplicate]