How to make a reverse string program in c programming language ?

Recommended Answers

your link is not valid. But here is how to do it

Jump to Post

All 3 Replies

your link is not valid. But here is how to do it

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.