What's Here?
- Members: 148,890
- Replies: 505,020
- Topics: 79,542
- Snippets: 2,661
- Tutorials: 705
- Total Online: 2,257
- Members: 87
- Guests: 2,170
|
Shows how a string can be reversed using Recursion.
|
Submitted By: born2c0de
|
|
Rating:

|
|
Views: 39,550 |
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
|
|
|
Be Social
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|