Reverse of a string using pointers

 

#include<stdio.h>
main()
{

int i,j,k,l;
char *p,*q,str[50];
printf("Enter a string");
p=str;
gets(str);

j=strlen(str);
printf("Reverse of the string is ");
for(i=j;i>=0;i--)
{
printf("%c",*(p+i));
}
}

 

Output: [Click to enlarge]:

Reverse_string

Leave a Reply

Your email address will not be published.