replace snprintf with C++ string