The special case of the array name of the C language __c language

Source: Internet
Author: User

To see the domestic textbooks that write:

But there are some special circumstances. First: Operands of an array as a & operator

#include <stdio.h>

int main (void)
{
    int a[] = {1,2,3};//creates an array
    int *l;//a pointer
    int (*P) that points to integers [ 3];//A pointer to an array
    l=a;//array name can only represent a pointer to an integer
//p=a;
    The p=&a;//array name address is the pointer to the arrays
    printf ("p=%p\n", p);
    printf ("l=%p\n", l);

    printf ("p+1=%p\n", p+1);
    printf ("l+1=%p\n", l+1);
    return 0;
}

In this example, the array name of a, in p=&a;, does not represent the address of the first element of the array, but represents the entire array. The second scenario: the operands of the array as the sizeof operator.

#include <stdio.h>

int main (void)
{
    int a[] = {1,2,3};//Create an array

    printf ("size=%d\n", sizeof a );


    return 0;
}


In this example, the array name A, which is the operand of the sizeof, does not represent the address of the first element of the array.

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.