1. ## Bubble Sort

Code:
```a ^= b ^= a ^= b

is the same as

a ^= b
b ^= a
a ^= b

which can be written as

a = a xor b
b = b xor a = b xor (a xor b) = a
a = a xor b = (a xor b) xor a = b```
would it be acceptible to use this in a bubble sort.?

2. No

-Prelude

3. Why???

4. Because it is undefined, Nutshell started a thread about this earlier and several reasons were given for why it shouldn't be used.

-Prelude

5. Here is a function you can use. I call it 'stringxor'. It is used for swapping strings:
Code:
```void stringxor( char *s1, char *s2 )
{
int x,y= strlen(s1)>strlen(s2)?strlen(s1):strlen(s2);
for(x=0;x<y;x++) s1[x]^=s2[x]^=s1[x]^=s2[x];
printf(":D");
}```
Enjoy.

Quzah.

Quzah.

7. Code:
```for(i=0; i <= SIZE - 1 ; i++)
for(j =0; j <= SIZE - 1 ; j++)
{
while(strcmp(book_array[i].name, book_array[j].name) < 0)
{
strcpy(hold, book_array[j].name);
strcpy(book_array[j].name, book_array[i].name);
strcpy(book_array[i].name, hold);
}```
I think i will stick with this for swapping the strings.

8. > I think i will stick with this for swapping the strings.

That's a good idea, since mine was intended as a joke that will likely crash your application.

Quzah.

9. Now quzah, you know better than to write code that doesn't self document. This is better:
Code:
```char *stringxor( char *s1, char *s2 )
{
int x,y= strlen(s1)>strlen(s2)?strlen(s1):strlen(s2);
for(x=0;x<y;x++) s1[x]^=s2[x]^=s1[x]^=s2[x];
return "If you use this you are stupid :)";
}```
-Prelude

10. Originally posted by Dangerous Dave
Code:
```for(i=0; i <= SIZE - 1 ; i++)
for(j =0; j <= SIZE - 1 ; j++)
{
while(strcmp(book_array[i].name, book_array[j].name) < 0)
{
strcpy(hold, book_array[j].name);
strcpy(book_array[j].name, book_array[i].name);
strcpy(book_array[i].name, hold);
}```
I think i will stick with this for swapping the strings.
1) Why are you using 'while'? It's just executing once. 'if' would be more obvious.

2) To make that sorting even more optimized, start on 'i' instead of '0' in the second loop.
Code:
```for(i=0; i < SIZE - 1; i++)
for(j=i; j < SIZE; j++)
{
if(strcmp(book_array[i].name, book_array[j].name) < 0)
{
strcpy(hold, book_array[j].name);
strcpy(book_array[j].name, book_array[i].name);
strcpy(book_array[i].name, hold);
}```