use locale::classic() instead of locale(C) (thanks to @aschnell)
improve C++ code (thanks to @aschnell)