C program to reverse a string

There are many methods to reverse a string in C. Basically, reverse a String means, we have to take a string to display the string from backwards. Let’s take an example,

Consider that user input a string “reverse“.So, we have to write a c program which gives us the output “esrever“. Reverse a string in c can be done using pointers, a built-in function called strrev, and without strrev.

Reverse a String in C

C program to Reverse a String using Strrev

strrev() is built-in library function comes under the header file string.h.What strrev() does, it takes the input value and reverses it automatically.


C program to take User input to Reverse a String

Taking the user input from the C program using gets() function.


C program to Reverse String Without Using strrev function

Reverse String Without Using strrev function.Take user input from the user then swap the characters one by one in reverse using while loop.


C program to reverse a string using pointers

Reverse the string using pointers without using the library functions.

or

You can check how to Reverse a String in java here or you can visit quora