Write a C program to reverse the string without using strrev() ?

Write a C program to reverse the string without using strrev() ?

This is simple logic which can reverse whole string without using library function strrev( ) or any other temporary string, we just use one temporary char variable. 

 

 

Probable errors : Here strlen( ) gives you the length of string without null character and we minus 1 from complete length because our for loop will start with 0(zero). If you do not minus length of string by 1 then your printf function will not print anything because you shift last null character on first position and string will end before start.

Reverse string using recursion

 

Output

Reverse a string without using strrcv

 

Suggested Reading

  1. Write a C program to reverse the words in a sentence in place
  2. Write your own trim() or squeeze() function to remove the spaces from a string
  3. Write a C program which does wildcard pattern matching algorithm

If you like this Article, then don’t forget to Click on Social likes buttons.