Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #define SWAP(T, a, b) \
- do { T save = (a); (a) = (b); (b) = save; } while (0)
- char *reverse_string(char *s)
- {
- size_t len = strlen(s);
- if (len > 1) {
- char *a = s;
- char *b = s + len - 1;
- for (; a < b; ++a, --b)
- SWAP(char, *a, *b);
- }
- return s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement