-
Scope. You static char *chh;
static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times().
People are already hanging, and you still want to dig up the whip corpse, you are too ruthless.
There are other ways to do this, but I recommend that you change that first.
char chc[10];, change it to a global variable, and adjust it yourself.
-
Wow that's a long time, what's the problem? You don't say anything, how do I answer it?
-
Describe the problem clearly, is there a bug in this program, or you can't get the desired result、、、
-
Static: The address will not change, it will always be in memory until the program is terminated.
-
static changes the duration of local variables.
For example, you here, after the first execution.
CHH is 15 (for example).
Until the next execution, *chh is still 15
Static changes the visible range of global variables, originally the global variable is accessible to all programs, if static is added, it can only be accessed by this subprogram.
As in the case by more than one. c(.cpp) file, in order to prevent other source files, a global variable with the same name is defined, and a static is added in front of it to solve the problem.
-
int a[2][3], p[3];
Analysis: For a, there is no doubt that a is a two-dimensional array, and the value of a zhi points to the origin dao address of the int type. Inside.
For p, first p comes first'[ ]'Combined with p[3], it means that p-is an array, and p is then with'*'Combined' *p[3] ', which represents the time pointer variable stored in the p array, and finally combines it with the int type' int *p[3] ', which indicates that the array is stored with a pointer of type int.
p[0]=&a[1][2];
So the value of p[0] is a pointer to type int.
The value of a[1][2] is an int type, plus'&'The result is a pointer to the int type.
So p[0]=&a[1][2]; Establish.
It is recommended that ZL check out "Let You No Longer Be Afraid of the Pointer".
-
*p[3] is an array of pointers, and each array element is an int pointer.
The mistake with a is that p is the pointer to this pointer array, and if you change the value of p, then this pointer array will become garbage.
-
*p[3] This is the pointer array, and the elements inside it are the pointers.
Normally, A is fine, but it may be an error. A forced turn is required, but addressing is fine.
-
If there is a definition statement: zhiint a[2][3], *p[3]; Then the correct DAO in the following statement is (c).
a. p=a;Error, anachronic answer mismatch.
Error, type mismatch.
That's right. Error, type mismatch.
The test procedure is as follows. The following program can be compiled successfully, and replacing it with something else will not succeed.
#include
void main()
Operate from right to left, -i--so calculate -i first--, the operation level is higher, so it can be written as -(i--)i--for 8, add a - sign, so -i--is 8, at this time i--after, i=7, and then -i++ is the same, can be written as -(i++) so -i++ is -7, at this time i++ becomes 8,--i, subtract 1 before execution, so --i is 7, at this time i=7, ++i is the same, add 1 before executing i, so ++i is 8, at this time i=8, then calculate i--,i--is still equal to 8, then i minus one becomes 7, i++, i++ is equal to 7, and then i++, i=8, so finally i=8, and then print it out in turn, pay attention to the operation is from right to left, but print from left to right print i,i++,i--,i,--i,-i++,i-, so the check mark result is out.
2. 1, True 2, False (there is only one program) 3, False (not necessarily) 4, True. >>>More
C++ is an object-oriented language, not very easy to learn, because it is more flexible, so there are a lot of problems to consider when doing programs! Because of the direct operation of the hardware, it inherits the advantages of the C language, so it is very efficient, and is generally used for the underlying and embedded systems.
#include
int main() >>>More
This problem requires understanding that the system allocates memory to static variables when compiling, and the memory units occupied by them are not released after the function call ends, that is, the value of the variable is the value of the previous function call at the next function call. >>>More