I'm using sprintf(newpath, "%s%s", cCurrentPath, "\\init.scm");
to add \init.scm to current dir path but there is the usual warning:
warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
Sprintf_s
doesn't support such "%s%s" string sum. How can I do it using sprintf_s
?
sprintf_s
is basically the same as sprintf
, but it gets another parameter:
sprintf_s(newpath, sizeof(newpath), "%s%s", cCurrentPath, "\\init.scm");
Note - if newpath
is a normal character array, sizeof(newpath)
works. If it's a pointer or an array passed as an argument, you may need a different way to get the size.
You can also use snprintf
for the same purpose in a non-MS environment (though it works differently).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With