Use snprintf instead of sprintf.