Can anyone suggest a method as to how i can perform a destructive string reversal?
Can anyone suggest a method as to how i can perform a destructive string reversal?
What do you mean destructive? Are you trying to blow up the string? LOL.
Or do you just want to reverse all of the characters in a particular buffer? In that case, have one pointer pointing to the start of the string and another one pointing to the end of it. Swap, swap, swap......
I think he means reverse the string, destroying the original (ie doing it in the same var)?
there are sample on the board - use search.
Idea is to make two pointers: src is pointing to the beginning
dst to the last char
after copy char - you advance src one char forward and dst one char backward.
You stop when dst <= src (in the midlle of the string)
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
ok guys... lets slow down, im a newbie here
i dont even really know for sure what a destructive string reversal is...
all i know is that, if i made an array of characters, and typed out a string, Hello, for example,
the program would reverse the characters of the string, and print back to the screen olleH
so ill try w/ the 2 pointers then, see where that leads me, i guess...
As vart said, create a pointer at the start and a pointer at the end, iterate through them (to swap the chars)... Just make sure you stop at the middle
see MacGyver's post, then see his sig.
haha, good way to get help. You should go on freenode #c and ask the same question perhaps?
Somewhere, where you'd be put in your place...
Here you go, it won;t take not 2 min to search the board
http://cboard.cprogramming.com/searc...earchid=650471
ssharish2005