An introductory programming question about C pointers!

Updated on educate 2024-03-16
8 answers
  1. Anonymous users2024-02-06

    Reads characters and counts to'\0'Come to an end!

  2. Anonymous users2024-02-05

    The C program written according to the requirements of the question is as follows (see figure).

  3. Anonymous users2024-02-04

    The password is 5 digits, which is the least common multiple of and 104.

  4. Anonymous users2024-02-03

    Answer]: A This question tests the basic knowledge of programming languages. Variables are memory unit abstractions that are used to represent data in a program.

    When the variable storage is a memory unit address, it is called a pointer variable, or a pointer variable points to another variable. Pointer variables can be defined within a function or compound statement, or outside all functions, i.e., they can be global or local. You need to distinguish between a pointer variable and a pointer variable, no matter what variable the pointer is pointing to, its storage space is the same.

    When a pointer variable points to an element in an array, performing an arithmetic operation on the pointer variable can point it to other elements in the same array.

  5. Anonymous users2024-02-02

    while (*y++)

    Because the ++ operator has a higher priority than *, add 1 to the pointer y first, and then take out the character that pointer y points to.

    If the character is not 0 (0), it will be looped.

    Because the string array a= is by character'\0'Ending, character'\0'The ASCII code value is 0

    This is when the pointer y points to'\0'to end the cycle.

    return (y-x-1)

    y x is a pointer, which is a memory address, and y-x-1 returns the result of the operation by subtracting and subtracting 1 from the two pointers.

    Judging from the actual execution results, 5 is returned

    So y-x=6

    In fact, it was actually looped 5 times, but the difference between the two pointers y and x was 6 because the priority of ++ was higher than *.

    Hope mine is of some help to you, it is a pleasure to discuss and learn C language with you.

    The pointers of the C language are relatively difficult to understand and require a lot of practice to master.

  6. Anonymous users2024-02-01

    First of all, the store in A is like this.

    while(*y++)

    This pointer traverses the entire array of strings until'\0'End, at the end of the more ++ so after -1.

    return(y-x-1);

  7. Anonymous users2024-01-31

    A pointer in a C function. In this case, you can temporarily understand that the arguments passed in the main function are specific, and they have been modified in the function you wrote, so the main function is also the modified data in the obtained data. If you don't take the pointer away, it's like two children copying homework, and no matter how the child copying the homework is, the content of the homework's work remains the same.

    But with a pointer, it's as if someone else copied his homework and wrote it directly in his homework book. The student who copied the homework did not have his own homework book, but used someone else's homework book. Is it okay for me to say that?

    It doesn't seem to be clear, but if you have any other questions, you can continue to ask.

  8. Anonymous users2024-01-30

    *y is a pointer, so while(*y++) is a skelet.

    returen() is the return value of the function, which means that the value of the fun() you created is equal to the return value after running.

    In general, it is a program that calculates length, and you can find out how the -1 in return(y-x-1) comes from.

Related questions
4 answers2024-03-16

It's not very hard that the tail node next points to null. >>>More

9 answers2024-03-16

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

18 answers2024-03-16

Indeed, this ** amount is not something that can be done by dozens of lines, it belongs to commercial applications, so let's spend money to buy it.

7 answers2024-03-16

#include

using namespace std; >>>More

15 answers2024-03-16

The ratio of homozygotes to heterozygotes in the second generation of medium-dwarf disease resistance is 1:2, that is, heterozygous accounts for two-thirds. The offspring of these heterozygous self-inbred offspring are one-quarter disease-resistant homozygous and one-half heterozygous. >>>More