SCANF () The dual usage input returns a numeric value based on the input: for example status=scanf ("%ld", &num)///////return 1 after the successful entry to Stasus returns 0 when the input is not a number. You can use this usage as a comparison expression. Compare size: Use relational operators and expression relational operators to compare numbers, characters, floating-point numbers (only < or >), and not to compare strings. Const (reproduced here)
The role of the Const keyword has the following main points:
(1) A const constant can be defined with immutability. For example:
const int max=100; int Array[max];
(2) Easy to type check, so that the compiler to deal with the content of more understanding, eliminate some hidden dangers. For example: void f (const int i) {...} compiler will know I is a constant, not allowed to modify,
(3) can avoid the ambiguous meaning of the number, the same can easily adjust and modify the parameters.
(4) can protect the modified things, prevent accidental modification, enhance the robustness of the program. Or the example above, if I was modified in the function body, the compiler would have an error; for example:
void f (const int i) {i=10;//error!}
(5) Provides a reference for function overloading.
class A {...
.. void f (int i) {...}//a function
void f (int i) const {...}///Previous function overload ...
};
(6) Can save space and avoid unnecessary memory allocation. For example:
#define PI 3.14159//Chang
const DOULBE pi=3.14159//The PI is not put in
rom at this time ... Double I=pi; The pi allocates memory at this time and is no longer assigned.
double I=PI//macro substitution during compilation. Allocate memory
double J=PI///No memory allocation
double J=PI//macro substitution, and memory allocated again.
const defined constants from the assembly point of view, just give the corresponding The memory address, rather than the immediate number given in the same way as #define, the const-defined constant has only one copy during the program's operation, while the #define-defined constant has several copies in memory.
(7) Improve the efficiency. Instead of allocating storage space for ordinary const constants, the compiler saves them in a symbol table, which makes it a constant during compilation, without the operation of storing and reading memory, making it highly efficient.
A Boolean variable (_bool) that represents a true or false variable is assigned to it, i.e. 1, false or 0. Include stdbool.h file to rewrite _bool to bool