Program reverse of given string using pointer.

use header file as string.h

void main()
{
char str[20],rev[20];
int i,l,j;
char *p;
clrscr();
printf("Enter the string\t");
scanf("%s",str);
p=str;
l=strlen(str);
p=p+l;
for(i=l;j=0;i>=0;i--;j++)
{
rev[j]=str[i];
}
rev[j]='\0';
printf("\nThe reverse is %s,rev);
getch();
}

No comments:

Post a Comment