What's Here?
- Members: 300,293
- Replies: 825,467
- Topics: 137,351
- Snippets: 4,417
- Tutorials: 1,147
- Total Online: 2,143
- Members: 116
- Guests: 2,027
|
Shows how a string can be reversed using Recursion.
|
Submitted By: born2c0de
|
|
Rating:

|
|
Views: 57,790 |
Language: C++
|
|
Last Modified: March 2, 2008 |
Instructions: NOTE:
This code might be the shortest...but is not the best when it comes to performance. |
Snippet
/*
Recursive Reverse String Algorithm
The Shortest function to reverse a string.
Written by: Sanchit Karve
born2c0de AT hotmail.com
[born2c0de]
*/
#include <iostream>
using namespace std;
void ret_str(char* s)
{
if(*s != '\0')
ret_str(s+1);
cout<<*(s);
}
int main()
{
ret_str("born2c0de");
return 0;
}
Copy & Paste
|
|
|
|