Tuesday, 30 September 2014

WAP to Reverse String with the use of Pointer

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
char a[100],b[100];
char *str=a;
char *rev=b;
int i=-1;
printf("\n\t Enter String : ");
scanf("%s",&a);
while(*str)
{        *str++;
i++;
}
while(i>=0)
{
*str--;
*rev=*str;
*rev++;
i--;
}
*rev!='\0';
printf("\n\tstring in Reverse :  %s  ",b);
getch();
}

No comments:

Post a Comment

Please write your doubts