There is no point involving formatting logic in this; use strlcpy() rather than snprintf().