By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,121 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,121 IT Pros & Developers. It's quick & easy.

secury swprintf without crt

P: n/a
Hi ,
i have advice on the folloing code:
wchar_t* day = new wchar_t [11];
swprintf(day,L"%4d-%2d-%2d",yy,mm,dd);

how to make sure that my 'day' didn't get string bigger then 20 chars?

found:
swnprintf_s(day,size,L"%4d-%2d-%2d",yy,mm,dd);
but it requires crt

any suggestions?

~igRek

Dec 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ig****@gmail.com wrote:
Hi ,
i have advice on the folloing code:
wchar_t* day = new wchar_t [11];
swprintf(day,L"%4d-%2d-%2d",yy,mm,dd);

how to make sure that my 'day' didn't get string bigger then 20 chars?

found:
swnprintf_s(day,size,L"%4d-%2d-%2d",yy,mm,dd);
but it requires crt

any suggestions?
Yes. Don't use swprintf. Use a wostringstream instead.
Dec 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.