KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is snprintf always null terminating the destination buffer? In other words, is this sufficient: char dst[10]; snprintf(dst, sizeof (dst), "blah %s", somestr); or do you have to do like this, if somestr is long enough? char dst[10]; somestr[sizeof (dst) - 1] = '\0'; snprintf(dst, sizeof (dst) - 1, "blah %s", somestr); I am interested both in what the standard says and what some popular libc might do which is not standard behavior.
Tags (comma-separated)
Save Edits
Cancel