call snprintf on POSIX systems and sprintf_s on Windows