Arrays Decaying to Pointers

Please help me understand the programs below.

#include<stdio.h>
int main()
{
    int a[7];
    a[0] = 1976;
    a[1] = 1984;
    printf("memory location of a: %p", a); 
    printf("value at memory location %p is %d", a, *a); 
    printf("value at memory location %p is %d", &a[1], a[1]);
    return 0;
}

&a[1]and &a+1. Are they the same or different?

#include <stdio.h> 
int main() 
{
    int v[10];
    int **p; 
    int *a[5];
    v[0] = 1234;
    v[1] = 5678;
    a[0] = v; 
    a[1] = v+1;
    printf("%d\t%d\t%d\t%d\n", *a[0],*a[1],a[0][0],**a);
    printf("%d\n", sizeof(v));
    return 0;
} 

I wanted to know how it was *a[5]presented in memory. Is a *abase pointer that points to a[0],a[1],a[2],a[3],a[4]?

#include<stdio.h>

int main()
{
    int v[10];
    int **p;
    int (*a)[10];
    a=&v;
    printf("%d\n",*a);
        return 0;
}

a=v; // gives error why?here vsplits into *v. Then &vsplits into (*)[]v? and means const-pointer. Here, how can I set a constant pointer to a pointer that is not a constant, without typecast?

Where the array is stored in memory. Whether it is stored in the memory data segment.

#include<stdio.h>

int main()
{
    int carray[5]={1,2,3,4,5};
    printf("%d\n",carray[0]);
    printf("%d\t%d\t%d\n",sizeof(carray),sizeof(&carray),sizeof(&carray[0]));
    return 0;
}

Edition:

, , , , sizeof &. sizeof(&carray) 4. &carray (*)[]carray r.

, sizeof &, .

+5
3

&a[1] &a+1. ?

Different. &a[1] (a+1). x[y] *(x+y).

, *a[5] . *a , a[0],a[1],a[2],a[3],a[4].

a . *a[i] - , th . *a a[0], ( ).

a=v //why this gives error

a ( ) . a, v ( );

a = &v;

, , C.

, .

+5

, , :

int *a and int a[]

, , [] , * a , 1

int *a[] and int **a

- Array, Matrix, , * a [] , , ** a , , , .

:    * :

int a;

& a → & (int) = int *

* *

int * a;

* a → * (int *) = int

int *a;
&a - the Address given to the pointer a by the system(pointer of pointer = **a)
&a+1 - the Address to the beginning of the array + 1 byte
&a[1] == &(a+1) - the Address to the beginning of the array + 1 size of int

int **a;
*a == a[0] - the Address of the first Array in the array of arrays a
*a[0]==a[0][0] - the first int of first array

int *a, b[5];
*a=*b - ERROR because a points at garbage to begin with
a=b - a points at array b

, .

-3

& a [1] & a + 1. ?

, , a, , sizeof (int), + 1 .

, * a [5] . D * a , [0], a [1], a [2], a [3], a [4].

a , 5. & a , & a [0]; & a [1] & a + sizeof (int).

= v;// , ? v * v.

, a , v . v (& v) .

v * v

. . v &v[0] ( , &*v), v[0] ( *v, )

-4

All Articles