Originally Posted by

**willgoodenough**
Smokey,

I'm understanding that the section of code is incrementing the pointer str1 and str2 together on a continuous loop until it reaches a zero value. hense why it is important to have that zero value or else it will keep going forever.

What I was getting at is that the result of an assignment is the value that is assigned. So when it encounters a 0 in *str1, it assigns it to *str2, so the result of the expression is 0, so the loop ends. It wouldn't terminate if there was no 0 in str1 but there was one in str2. It's a bit more obvious that assignments return the result of the assignment if you think of

to answer your bitwise question... i suppose i could AND it to a 0000000001 int and it will tell me if that bottom bit is set to 1 or not.

Yep!

Code:

unsigned int Reverse(unsigned int var1)
{
unsigned int reversed = 0; // reversed number goes here
// in here need a loop which takes 16 bits of var1
// and writes them in reverse into reversed
// we know we can find out if the bottom bit is set with
if (var1 & 1)
// so then we know we need to put a 1 or a 0 into reversed
return reversed;
}

Not very helpful ha!

So, you need to figure out what happens in that loop. The way I'm seeing it is you examine a bit in var1 then write a bit in reversed. There's more than one way you could do this -- and probably much more efficient ways with clever bit manipulation.

Time to think about shifts...