Using snprintf instead of sprintf to avoid libc errors.