The following code is designed to create a simple exit condition. If the user types 'exit', the program exits. But before I get to that, I need to use strncmp to evaluate the character array to determine that this is what the user entered.
I type 'exit' into the terminal, but strncmp doesn't evaluate to 'true'. Why? What am I missing? Thanks!
You might not agree with them, but that doesn't alter the fact that they have marked strcmp, along with a lot of other calls, as deprecated.
warning C4996: 'sprintf': This function or variable may be unsafe. Consider using
sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online
help for details.
1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\stdio.h(371) :
see declaration of 'sprintf'
Andy
It's strcpy, etc (and sprintf) I was mis-thinking about...
It is only the problem of Microsoft. As for others then that stupidy of Microsoft only annoys programmers.
By the way I would like to remind you that the Microsoft compiler is very bad and has numerous bugs.
You're encouraging someone to use strcmp, which is buggy. That's the reason why strncmp was written in the first place. I've seen, and used, buffer overrun attacks, and they're highly amusing.
Why should we teach someone to start using bad habits when it can get them in trouble later? That's like encouraging someone to use system() calls instead of cin.ignore().
Cause and effect, stupid. First you don't know what calculus even IS, now you're saying that it's impossible for bugs to cause a function to be unsafe?
You might not agree with them, but that doesn't alter the fact that they have marked strcmp, along with a lot of other calls, as deprecated.
It doesn't matter what Microsoft says (or I do). These functions are not deprecated in or by the standard, therefore they are not deprecated. The warning is useful. It is a shame it is misleading.
Moreover using strncmp is this example is indeed a bug!:) The user could enter some word that has initial letters as exit but the whole word entered by the user is not equal to exit. For example the user could enter "exit poll".:)