In this section, you will study how to reverse a string. You can see in the
given example, a recursive function reverse(int i) is created. Inside
the method, we are calculating the length of a specified string using a library
function strlen(). Then string st[i] and st[strlen(st)-i-1]
are swapped as:
c= st[i];
st[i]=st[strlen(st)-i-1];
st[strlen(st)-i-1]=c;
Statements shown above will reverse the string.
Here is the code:
StringReverse.C
#include <stdio.h>
|
Output will be displayed as:
STRING~1.EXE

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: C String Reverse View All Comments
Post your Comment