sprintf
sprintf: http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/Portotype: int printf(char* str, const char* format, parameters);
Writes into the array pointed by str a C string consisting on a sequence of data formatted as the format argument specifies. After the format parameter, the function expects at least as many additional arguments as specified in format.
This function behaves exactly as printf does, but writing its result to a string instead of stdout. The size of the array passed as str should be enough to contain the entire formatted string .
Return value:
On success, the total number of characters written is returned. This count does not include the additional null-character automatically appended at the end of the string.






//same as int flag1 = sprintf(str,"%s is written to str.","Test","tEST");












// 在dev c++不能運行,vc6.0沒有問題






沒有測試出什么時候出錯返回負值呢!!誰給我一個例子?
posted on 2010-04-25 19:23 幸運草 閱讀(494) 評論(0) 編輯 收藏 引用 所屬分類: C++