secury swprintf without crt

I

ig3v10

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
 
R

red floyd

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,082
Members
48,773
Latest member
Kaybee

Latest Threads

Top