Pointer ++, pointer record pointer address, negative subscript reference

Source: Internet
Author: User
# Ifndef _ test_h # DEFINE _ test_h // you can understand the pointer as an address. An address can record a data address, and a pointer is also a // data type, therefore, the pointer can also record the address of a pointer. # Include <iostream> using namespace STD; void main () {// pointer resolution reference *: obtains the value stored in the address space stored by the pointer, depending on the Data Type length, // The addition and subtraction P ++ of the pointer: the length of the addition and subtraction is the length of the number of bytes of the Data Type pointed to by the pointer, the value of P is changed to the address of the next pointer // pointing to the Type Bucket. (the key here is to identify which pointer is used for the operation.) // The subscript P [-1] of the pointer is used to retrieve * (P-1 ), the P value will not be changed. // when the disassembly pointer is added, it is in bytes. // because short is 2B and PTR is the pointer of this type, so when PTR ++ points to the next short unit // records the short address short int A = 3; short int * PTR = &; cout <PTR <Endl; PTR ++; cout <PTR <Endl; // at this time, p is the pointer of PTR and records the PTR address, PTR is an address of the pointer type. On 32 machines, the address length is 4B, so P ++ points to the next four-byte unit after PTR, the record is the address short int ** P = & PTR; cout <p <Endl; P ++; cout <p <Endl; short int B = P [-1] [-1]; cout <B <Endl ;}# endif // _ test_h

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.