Swapping elements of two distinct arrays in C without using temporary variable
i have two array's say int array1[6] = { 2, 4, 5, 7, 9 }; & int array2[6] = {0 ,5 ,6 , 7, 3}

I will pass these to a function swap(array1,array2)

I am currently trying to do it as below

    index =0;
    while(array1[index] && array2[index] != NULL)
    {
        array1[index] = array1[index] ^ array2[index];
        array2[index] = array1[index] ^ array2[index];
        array1[index] = array1[index] ^ array2[index]; 
        index++;
    }
    

Is my approach correct? Please let me know your views


Thanks

Swapping elements of two distinct arrays in C without using temporary variable
===

i have two array's say int array1[6] = { 2, 4, 5, 7, 9 }; & int array2[6] = {0 ,5 ,6 , 7, 3}

I will pass these to a function swap(array1,array2)

I am currently trying to do it as below

    index =0;
    while(array1[index] && array2[index] != NULL)
    {
        array1[index] = array1[index] ^ array2[index];
        array2[index] = array1[index] ^ array2[index];
        array1[index] = array1[index] ^ array2[index]; 
        index++;
    }
    

Is my approach correct? Please let me know your views


Thanks
