Click to See Complete Forum and Search --> : Wrapper function for sprintf, strcat, strcpy?


donguymi
June 20th, 2009, 06:45 PM
Hello

I am working on VS2003 and using the above mentioned functions, but the compiler gives me warning saying those functions are #pragma depreciated.

I know VS2008 has functions like sprintf_s, but unfortunately i will not be able to upgrade to 2008.

So now i want to use a wrapper function around sprintf, which will do the additional work that sprintf_s will do and there by making sure that i call sprintf only once.

This new wrapper function should be able to check for buffer over run and then i will call sprintf inside this function.

What it will do is, it will make sure that, i only need to call sprintf once and that will bring down compiler warning to just one.

Is anyone aware of such a wrapper function? Or can anyone help write a wrapper?

Thanks in advance.

hoxsiew
June 21st, 2009, 10:08 AM
I may be wrong, but I thought that VS2003 had the _s (secure) versions of these otherwise why would it warn you that the old ones are deprecated?

As for writing your own wrappers, what's the problem?

ovidiucucu
June 22nd, 2009, 03:16 AM
To see what additionally do the "secure string functions", you can take a look in MSDN at Security Enhancements in the CRT (http://msdn.microsoft.com/en-us/library/8ef0s5kh(VS.80).aspx).