Ask C about the output of addresses

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

    However, it is clear that this is problematic because variable a is not assigned at all.

    The third: the key to the symbol & addition depends on what you want to output, and what variable a is, which is determined by both.

    The process is a bit complicated.

    First, I will affirm the fruits of my labor, and then I will talk about it in detail.

  2. Anonymous users2024-02-04

    The first one: printf("%p",a)

    This is the value of output a.

    printf("%p",&a)

    This is the address where the main output stores the a-value.

    To output the address of the pointer variable b, just printf("%p",&b);

    Remember that there is an amperand sign, which indicates the address.

  3. Anonymous users2024-02-03

    The first, int a; The integer variable a is not assigned, so the value of a is garbled, and &a is the memory address of the a variable.

    the second, int*b; b is an integer pointer, after b=&a, the value of b is the memory address of the a variable, and if the address of b is output, then it is &b

    Third, what symbols are needed to be related to your needs, for example, if you want to print out the value of a, then it is a, and if you want to view the memory address of a, then you will &a

  4. Anonymous users2024-02-02

    printf("%p",a);and printf("%p",&a);The difference is that the former outputs the address of a, while the latter outputs the address of the parameter, and the address of a is stored in the parameter.

    The second fill in b is the address of the a variable, and you want to output the address of the pointer variable b and fill in &b

    The third & takes the address, which is used when outputting variables, but not when outputting pointers.

  5. Anonymous users2024-02-01

    It can be understood that the memory is a big hotel, and the rooms in it have house numbers, which are the value of the address, and the room is a space (how big is the space?). For example, int can be calculated with sizeof(int)).

    This address is worth and is represented by &x (hex) in hexadecimal. Or %p print address.

    The (first) address of the array is the name of the array, e.g. int s[10], where s is the address.

    The pointer, p is the pointer itself, and *p is the address stored in the space (in the room, p has its own room number, and *p is a room number stored in p's room).

    But when you really use it, you generally don't use the address to do the operation, but use the data in the address. gets(s) is also an input of data into the contiguous space of this address.

  6. Anonymous users2024-01-31

    CPU registers and memory will define the starting address as zero, and then use the offset to find the corresponding address. For x86, the address is an unsigned int that occupies 4bytes; x64 is an unsigned int with an address of 8 bytes

  7. Anonymous users2024-01-30

    is a specific number.

    In the memory space, these data are stored in the memory space, how to find it, is to find it by the address.

    Binary bits are the most basic units called bytes

    The computer makes a group of 8 of these bits into bytes.

    Number each byte, this is the address, through this address, you can find the data you want like a community, want to find an owner, through a few buildings, a few units, a few floors to find, hehe, two addresses can do subtraction operations (indicating how many bytes are separated between two addresses), or an address minus a constant.

  8. Anonymous users2024-01-29

    That's an interesting question:)

    An address is an address, just a string of numbers.

    If you want to output the corresponding content, then you need to know two things:

    a, you need to know how many bytes of memory you need to save this content, in other words, you need to know how much you need to explain.

    How many bytes of memory space can be used to output the contents of the storage;

    b, the second thing you need to know is how to interpret this length of memory, whether it is explained in terms of unsigned integers or single-precision floating-point numbers.

    In C C++, the concept that tells you both of these things is the type of data that is stored at the address.

    So, let's say you only have one address of type ul on hand, and you want to interpret the four bytes at that address as none.

    sign integer, then you have to write something like this: *unsigned int *)0xabcdef12 ; Otherwise, it is to be interpreted as monosperm.

    0xabcdef12 begins with a byte (note that it's not four bytes, but a byte) is interpreted as an unsigned

    char, here's how it works: *unsigned char *)0xabcdef12.

    So, what type of long bytes you interpret and what kind of content you can take out is up to you. :

  9. Anonymous users2024-01-28

    As long as the address is not empty, it can be output.

Related questions
9 answers2024-02-09

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

14 answers2024-02-09

First question: What does exit failure mean? Why do you need this thing in this program? >>>More

7 answers2024-02-09

I don't understand what you're talking about, but you've probably just learned to shop online. Look at what you said, you should have sent the money to the seller through Alipay, and the seller chose the "consignor pays postage" when you ship the goods, so the courier did not collect it from you. >>>More

31 answers2024-02-09

If it's just a system.

Files other than the system disk (C drive) will not be lost. >>>More

27 answers2024-02-09

In this case, the ball should be regarded as Party B touching the ball out of bounds, and Party A's right to the ball shall be continued by Party A to throw the throw-in!! >>>More