A bit too much here to put in a comment.
I use a version of Visual C but it never complains about the return value from scanf
not being used. What it does is to complain that scanf
is unsafe and deprecated, when it isn't.
MS thinks I should be using its own "safer" version scanf_s
which is even tricker to use and IMO no safer at all – because it is not a like-for-like replacement but takes different arguments, and so it is easy to make mistakes in using it.
One consequent problem is the compiler issues a warning for every use of scanf
(and some other functions) which obscures other warnings. I deal with it as advised by adding a #define
before the first library header inclusion.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
There are other matters which MS warns about too, and I actually place three #defines
at the start of each file:
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#include <stdio.h>
And now the relevant warnings are easy to see.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…