Search code examples
cpointersimplicit-conversionpointer-arithmetic

Reference data from a array to another array in C


I want to reference new array to address from another array in C code like this:

int main()
{
    int a[6] = {1,2,3,4,5,6};
    int b[6];
    unsigned long long int *c = &a[5];
    unsigned long long int *d = &b[5];
    int size = 6;
    for(;size>0;size--,c--,d--){
        *d = *c;
    }
    return 0;
}

but my code didn't work. can you tell me whats wrong in this code?


Solution

  • The data type of your pointer doesn’t match the data type of the array