>What is the easiest way to reverse a sting?
If your compiler supports strrev or anything similar then that's the easiest way. Otherwise, a loop that walks from either end of the string toward the middle and swaps until the two indices are the same would come a close second.

Now I only called the function my_strrev() because any previous header file or DLL linkage might try figthing over which function to use and etc...

I take my hat off to noob2c for finding this function :) I'm making a replica of the string library, so many thanks, I'll have to add this implementation to my project.

Edit (after noob2c post): Ah, ok. Much thanks to you too Prelude :)

Hope this helps,
- Stack Overflow

04-16-2004

noob2c

no problem..... it was prelude who knew the name of the function .... i did a search to find it. As for ^= that means exclusive or or XOR

04-16-2004

Thantos

Exclusive OR (XOR) returns true only when the two values are different.
Truth table for XOR:

Code:

0 1
0| 0 1
1| 1 0

^ is a bitwise XOR so if you have:
1010 and 1101 you would get: 0111

04-16-2004

Thantos

I always prefer to take the easist route until I'm sure of what is going on. As such I would recommend what Prelude suggest and avoid the codes that use ^= until you are 125% sure you know what it is doing.

Below is a quicky I threw together that uses 0 tricks and should be easy enough to walk through. Hope it is of help: