作者dreamboat66 (小嫩)
看板C_and_CPP
標題[問題] snprintf的問題
時間Thu Mar 24 20:45:19 2016
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++ and G++
原本使用sprintf 但VC卻會用error的方式叫我使用sprintf_s
查了一下, 想說用snprintf 可以跨平台, 以下是我的測試程式
http://ideone.com/3m8JXn
這段code在VC可以跑出正確的數值(用sprintf_s也ok)
我不懂為什麼snprintf在這情況下會出現問題...
順便請教為什麼微軟要弄一個sprintf_s 這種非標準的函數...明明就有snprintf阿?
煩請各位解惑
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.218.186.168
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1458823523.A.A62.html
推 yvb: google: man posix snprintf , 點進去後, 找 overlap 字樣 03/24 20:59
推 kwpn: 專案設定preprocessor definition加_CRT_SECURE_NO_WARNINGS 03/25 16:37