Since in XOR linked list current pointer store the XOR of addresses of previous and next node.
my question is how do we XOR two pointers?

Recommended Answers

All 5 Replies

but bitwise operation can be performed only on integers

You can use intptr_t, which I believe is defined in stdint.h. It's an integral data type that is supposed to always be able to hold a pointer. If I'm not mistaken, it is part of the C99 standard.

can you please write how to do it using intrptr_t?

can you please write how to do it using intrptr_t?

Don't get confused with stuff like intptr_t. All you're doing is casting the value stored by a pointer (not the value stored by the pointed to object) into an integer type so that bitwise operators can be used on it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.