14

i am running a program on win 7 via visual studio 2008

and i am getting this error:

Error 4 error C3861: 'snprintf': identifier not found

i have included stdio header...

i don't know what else it can be missing

1

1 Answer 1

22

Looks like on Windows, the function is prefixed with a _. Also, the function is deprecated in favour of a safer one:

http://msdn.microsoft.com/en-us/library/2ts7cx93(v=vs.80).aspx

Sign up to request clarification or add additional context in comments.

8 Comments

snprintf_s is rather stupid, snprintf already takes the size of the buffer, what benefit does asking for it twice have? If you don't want to fill the entire buffer, just give a smaller size!
snprintf is a standard C function (new in C99). Microsoft's "deprecation" of it in favor of non-standard functions is highly questionable.
It's standard in a standard that MSVC++ does not conform to. As for the deprecation's merit, I can't really speak for that. The last time I did any kind of C coding in Visual Studio was quite a long time ago. It does seem rather odd that their version of it has a size and a bufferSize. Edit: A post that outlines MS' attitude towards C99 quite well: stackoverflow.com/a/146419/567864
I wouldn't say that the function is prefixed with a _ on Windows. It's not the same function; _snprintf is not compliant with the C99 requirements for snprintf. In particular, _snprintf does not guarantee NUL-termination and does not return the necessary buffer size if a larger buffer is required.
snprintf and vsnprintf are added with C99 standard support in VS2014. See blogs.msdn.com/b/vcblog/archive/2014/06/18/….
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.