Original Post
Hi, Just wondering whats the deal with all these unsafe printf related warnings in VC8, and how to "deal" with them, in a "safe" manner. For example, using snprintf is apparently unsafe because the last character in the buffer isn't gauranteed to be null. Does this mean all you need to do to make your code "safe" is:
char buffer[256];
_snprintf(buffer,256,"whatever");
buffer[255]=0;
So whats the point of _snprintf_s (new "secure" function), and why could the behaviour of snprintf not simply be redefined to do as above? (ie: and then I dont need to worry about those warnings anymore..) msvc8 headers btw:
_CRT_INSECURE_DEPRECATE _CRTIMP int __cdecl _snprintf(char *, size_t, const char *, ...);
_CRTIMP int __cdecl _snprintf_s(char *, size_t, size_t, const char *, ...);