Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- void reverse(char *s) {
- for (char *front = s, *back=s+strlen(s)-1; front < back; *front ^= *back, *back ^= *front, *front ^= *back, ++front, --back) {}
- }
- void test(const char* s) {
- char* tmp = strdup(s);
- printf("before: %s\n", tmp);
- reverse(tmp);
- printf("after: %s\n\n", tmp);
- free(tmp);
- }
- int main(int argc, char** argv) {
- test("hello, dingus");
- test("hello, dingus!");
- test("");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement