Question: During a recent interview one of my friends was asked a question to reverse a string using only a single line of code.
The string is already stored in a `char*` variable.

I tried using recursion, but it never reduced to a single line of code.

Could anyone help me with this?

Answer: 
1. Write a program which works.
2. Condense it all onto a single line. You don't need to have linefeeds between statements!
If you really want it in C, and `strlen` is allowed, this will work:

```
for( char *p = str, *q = str + strlen(str) - 1; p < q; *p ^= *q, *q ^= *p, *p++ ^= *q-- );

```

I do not recommend you to use this in any actual program... Anyone got an idea how to get rid of the `strlen`?

Edit: *even more beautiful*:

```
for( char *p = str, *q = strchr(str, 0) - 1, t; p < q; t = *p, *p++ = *q, *q++ = t );

```