1. ## help in XORring

I am trying to solve this code but its make me confuse all the time .can any one help me to correct this program.

Code:
int main()

{
int a[2]={29,33};
int *b[2];
int i,j,*linea[2],*lineb[2],*linec[2];

for (j=0;j<=1;j++)
{
b[j]=&a[j];

printf("value of a %d\n",b[j]);
}
for(i=0;i<=1;i++)
{
linea[i]=b[0];
linea[i]=b[1];
linec[i]= linea[i] ^ lineb[i];

printf(" %d\n",linec[i]);
}
getch();
}

2. What are you trying to do?

3. and what is wrong here?

Describe your problem if you want help with how to fix it

4. I am XORing 29 with 33 so my output will be 60..Thats I want acutally but i is showing error

Code:
Invalid Operands of types int* and int* to binary operator^
plz help me to solve it

5. The easy answer is "dereference the pointers to get the values". The real answer is "why do you have all these pointers anyway?"

6. Like this, perhaps?
Code:
#include <stdio.h>

int main(void)
{
printf("%d\n", 29 ^ 33);
return 0;
}
I cannot really tell what all that other code is supposed to do.

7. Originally Posted by mehakII
I am trying to solve this code but its make me confuse all the time .can any one help me to correct this program.

Code:
int main()

{
int a[2]={29,33};
int *b[2];
int i,j,*linea[2],*lineb[2],*linec[2];

for (j=0;j<=1;j++)
{
b[j]=&a[j];

printf("value of a %d\n",b[j]);
}
for(i=0;i<=1;i++)
{
linea[i]=b[0];
linea[i]=b[1];
linec[i]= linea[i] ^ lineb[i];

printf(" %d\n",linec[i]);
}
getch();
}

Okay, the code makes no sense, but the following bugs exist:
1. linea[i]=b[1];
Should be lineb
2. linec[i]= linea[i] ^ lineb[i];
linea[i] and lineb[i] are pointers. I think you mean:
linec[i]= *linea[i] ^ *lineb[i];
except that linec[i] can't be a pointer to an integer but should just be an array of integers.

I think that would make it work. But the rest of the code suggests to me that you really have no idea what you're doing, especially with pointers/arrays. Either that, or this is some very small snippet of a huge buggy piece of code.

My advice: read up on pointers and arrays before you code anything else.

8. I am writing my program in NES-C language ,the problem is I have to use pointers otherwise it gives me some other errors like

Code:
invalid conversation from int* to int
I want the same program with solution.

9. You don't necessarily have to use pointers; you are probably just not writing the code correctly. What exactly are you trying to do?

10. if I only use intergers then it gives me error invalid operands to binary