Home > Back-end >  C language for beginners
C language for beginners

Time:10-30

This where there is a problem?

CodePudding user response:

Microsoft's compiler now so bully? Turned out to be wrong rather than a warning?
There is something wrong with the code itself is no problem, the compiler let it
See the error message is that the scanf is considered to be unsafe (memory bounds may), so the compiler recommend using scanf_s
Instead of actually using scanf_s for transplantation, so you can define a _CRT_SECURE_NO_WARNNINGS macro to ignore the error message

CodePudding user response:

Changing the scanf to scanf_s, other unchanged; Suggest the building from the Internet search scanf_s usage, especially for % s, % ~ need to increase the parameters, such as c

CodePudding user response:

reference 1st floor qybao response:
Microsoft compiler now so bully? Turned out to be wrong rather than a warning?
There is something wrong with the code itself is no problem, the compiler let it
See the error message is that the scanf is considered to be unsafe (memory bounds may), so the compiler recommend using scanf_s
Instead of actually using scanf_s for transplantation, so you can define a _CRT_SECURE_NO_WARNNINGS macro to ignore the error message

The code to add in where? When I hit scanf_s debugging became a blank

CodePudding user response:

reference 2 building self-confidence boy reply:
change the scanf scanf_s, other unchanged; Suggest the building from the Internet search scanf_s usage, especially for % s, % c ~ need to increase the parameters, such as

Yes, I find thank you

CodePudding user response:

Error message shows the scanf function is safe the original poster can try the following code should be able to solve your problems
# define _CRT_SECURE_NO_WARNINGS
#include

Int Max (int a, int b)
{
If (a & gt; B) return a;
The else return b;
}

Int main ()
{
Int x, y, z;
Printf (" please input two integers: ");
The scanf (" % d % d ", & amp; X, & amp; Y);
Z=Max (x, y);
Printf (" Max=% d \ n ", z);
return 0;
}
The code is for reference only

CodePudding user response:

reference 5 floor weixin_49230444 reply:
error message shows the scanf function is not secure the original poster can try the following code should be able to solve your problems
# define _CRT_SECURE_NO_WARNINGS
#include

Int Max (int a, int b)
{
If (a & gt; B) return a;
The else return b;
}

Int main ()
{
Int x, y, z;
Printf (" please input two integers: ");
The scanf (" % d % d ", & amp; X, & amp; Y);
Z=Max (x, y);
Printf (" Max=% d \ n ", z);
return 0;
}
Code is only for reference

Thank you, the in the book I didn't succeed in his first line, why actual operation has a problem, this is the problem that the compiler?

CodePudding user response:

Syntax is different compilers commonly 99%, according to the standard, of course, there will be slightly different between different compiler, like this the scanf function, may not have errors in other compilers, but by the Microsoft compiler, must use Microsoft scanf_s function of "security", but in general, nothing too big error encountered a look at the error message on bend

CodePudding user response:

Thank you, I try

CodePudding user response:

I will, thank you for your
  • Related