int snprintf(char *restrict buf, size_t n, const char * restrict??format, ...);
函數說明:最多從源串中拷貝
n
-
1
個字符到目標串中,然后再在后面加一個
0
。所以如果目標串的大小為
n
???????????????? 的話,將不會溢出。
函數返回值:若成功則返回欲寫入的字符串長度,若出錯則返回負值。
Note:
???gcc下安全, VC下仍要注意
References:
平臺間函數差異與系統(tǒng)移植:snprintf/_snprintf
談談snprintf
strncpy, strncat和snprintf的區(qū)別
posted on 2008-09-03 13:43
季浩 閱讀(2502)
評論(0) 編輯 收藏 引用 所屬分類:
心得體會