The "works for me" mentality is one that you need to lose. Case in point:
Sample I/O:Code:#include <stdio.h>
int main(void)
{
int iScanRet;
char szSSN[15];
printf("Enter a SSN number: ");
fflush(stdout);
iScanRet = scanf("%[0123456789]",szSSN);
printf("iScanRet = %d\n",iScanRet);
printf("szSSN = %s\n",szSSN);
return 0;
}
As you can see, scanf() allowed me to overflow the buffer, yet it also signified success. Do you see the major problem with using scanf() to read strings? It's the same problem with using gets().Code:Enter a SSN number: 123456789123456789
iScanRet = 1
szSSN = 123456789123456☺
Overflowing a buffer should never be possible in a program that you write if you can help it. In this case, you can definitely help it.
Debating about insecure code should not be about preference. Reading strings using scanf() in the way that you are advocating is unsafe. Using gets() is unsafe. Using fgets() is safe.
You need to understand the difference between safe and unsafe. If you choose to use unsafe methods in your own code, that's your business although I will still say you should not do it. Do not use unsafe methods in commercial code or code that I or others should have to rely upon to be safe. You should always write portable code that is safe.

