What's Here?
- Members: 119,059
- Replies: 436,207
- Topics: 67,433
- Snippets: 2,417
- Tutorials: 641
- Total Online: 1,476
- Members: 71
- Guests: 1,405
Who's Online?
|
Welcome to Dream.In.Code |
|
|
Getting C++ Help is Easy!
Join 119,059 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,476 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
|
Shows how a string can be reversed using Recursion.
|
Submitted By: born2c0de
|
|
Rating:

|
|
Views: 34,800 |
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
|