What's Here?
- Members: 244,060
- Replies: 692,833
- Topics: 113,100
- Snippets: 3,863
- Tutorials: 935
- Total Online: 1,411
- Members: 94
- Guests: 1,317
|
Shows how a string can be reversed using Recursion.
|
Submitted By: born2c0de
|
|
Rating:
 
|
|
Views: 50,130 |
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
|