Questions about C pointers, C pointers

Updated on technology 2024-02-08
9 answers
  1. Anonymous users2024-02-05

    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.

  2. Anonymous users2024-02-04

    Wow that's a long time, what's the problem? You don't say anything, how do I answer it?

  3. Anonymous users2024-02-03

    Describe the problem clearly, is there a bug in this program, or you can't get the desired result、、、

  4. Anonymous users2024-02-02

    Static: The address will not change, it will always be in memory until the program is terminated.

  5. Anonymous users2024-02-01

    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.

  6. Anonymous users2024-01-31

    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".

  7. Anonymous users2024-01-30

    *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.

  8. Anonymous users2024-01-29

    *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.

  9. Anonymous users2024-01-28

    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()

Related questions
24 answers2024-02-08

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.

4 answers2024-02-08

2. 1, True 2, False (there is only one program) 3, False (not necessarily) 4, True. >>>More

15 answers2024-02-08

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.

12 answers2024-02-08

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