What's Here?
- Members: 131,825
- Replies: 470,023
- Topics: 72,842
- Snippets: 2,536
- Tutorials: 664
- Total Online: 1,572
- Members: 92
- Guests: 1,480
Who's Online?
|
Shows how a string can be reversed using Recursion.
|
Submitted By: born2c0de
|
|
Rating:

|
|
Views: 37,321 |
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
|
|
|
Reference Sheets
Bye Bye Ads
Free DIC T-Shirt
Related Sites
Monthly Drawing
Partners
Top Contributors
Top 10 Kudos This Month
|