![]() |
|
#1
|
|||
|
|||
Need help reversing an entered String with recursionHi there I am trying to write a short program to read in an entered string and then reverse it using recursion. my program is reading it ok but as far as I can tell its not stopping at the end of the string so it never prints the reversed string. Can any1 help out?
CPP / C++ / C Code:
|
|
#2
|
|||
|
|||
Re: Need help reversing an entered String with recursionQuote:
From my point of view, i don't this recursion is necessary. By running a for loop with a swap function is sufficient. CPP / C++ / C Code:
The for loop will run half for the string length times and calling the swapChar function. Take note, that swap from the start and the end of the string. Hope this helps!! } |
|
#3
|
|||
|
|||
Re: Need help reversing an entered String with recursionunfortunately the purpose of this program is to test recursion so I do need to use it.
|
|
#4
|
|||
|
|||
Re: Need help reversing an entered String with recursionJust look at what your program is doing.
CPP / C++ / C Code:
I would do it with something as follows.. CPP / C++ / C Code:
__________________
Music, programming, endless learning.. |
|
#5
|
|||
|
|||
Re: Need help reversing an entered String with recursionTake the below example it will work....
CPP / C++ / C Code:
Last edited by admin II : 05-Dec-2007 at 09:19.
Reason: Please surround your C code with [cpp] your code [/cpp]
|
|
#6
|
|||
|
|||
Re: Need help reversing an entered String with recursionKimmo has produced a good program here.
__________________
Linux is the best OS in the world. |
Recent GIDBlog
NARMY by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple questions for C++ project | devster420 | CPP / C++ Forum | 1 | 20-Apr-2007 21:26 |
| Message Class | TransformedBG | CPP / C++ Forum | 5 | 29-Nov-2006 21:28 |
| reverse a string using recursion | varun51 | C Programming Language | 1 | 13-Oct-2006 18:31 |
| variables return to previous value after i try to set them | nasaiya | MS Visual C++ / MFC Forum | 2 | 14-Jun-2005 00:43 |
| Help wit my source code compiler errors | Krandygrl00 | CPP / C++ Forum | 1 | 06-Jun-2005 08:14 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The