Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void str_reverse(char* str)
- {
- static char* head;
- char* tail;
- char tmp;
- if (!head)
- head = str;
- if (*str)
- str_reverse(str + 1);
- if (!head)
- return;
- tail = str - 1;
- if (tail <= head) {
- head = 0;
- return;
- }
- tmp = *head;
- *head = *tail;
- *tail = tmp;
- head++;
- }
- int main()
- {
- char s[] = "hello";
- //char s[] = "hell";
- //char s[] = "";
- str_reverse(s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement