作者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://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1458823523.A.A62.html
1F:推 yvb: google: man posix snprintf , 点进去後, 找 overlap 字样 03/24 20:59
2F:推 kwpn: 专案设定preprocessor definition加_CRT_SECURE_NO_WARNINGS 03/25 16:37