4
Contributors
3
Replies
6
Views
4 Years
Discussion Span
Last Post by rustysynate
0

In place reversal:

char * str <- "something"
char temp
i <- 0
j <- strlen(str) - 1

while (i <= j) do
    temp = str[i]
    str[i++] = str[j]
    str[j--] = temp
end_while

On another char*

char * str <- "something"
char rev [strlen(str)]

i <- 0
j <- strlen(str)

for j downto 0 do
    str[j] = rev[i++]
end_for
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.