On the identification of the address of the array (&s+1,s+1,&s[0]+1)

Source: Internet
Author: User

1#include <stdio.h>2#include <malloc.h>3 4 intMain ()5 {6 CharS1[] = {'H','e','1','2','o'};7 Char*p= (Char*) (s1+3);8printf"*p:%c\n"-P:0]);9 Char*p2= (Char*) (&s1[0]+4);Tenprintf"*p2:%c\n", p2[0]); One Char*p3= (Char*) (&s1+1); Aprintf"*p3:%c\n", p3[-1]); -  - return 0; the}

Output:
*p:2
*p2:o
*p3:o

Before this, the array value is always unable to distinguish between the difference between the s1+2,&s1[0]+2,&s1+2, today deliberately tested under, the original their differences are as follows:

S1+2:

Refers to the value of 2-bit from the beginning of the S1 array 0 bits.

&s1[0]+2:

As with S1+2, the 2-bit value is moved down from the 0 bits of the S1 array.

Special Note: &s1+1:

Refers to moving to the next position of the S1 entire array, which is equivalent to moving out of the S1 array.

On the identification of the address of the array (&s+1,s+1,&s[0]+1)

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.