program to reverse the string by using pointer..

#include<stdio.h>
char* reverse(char*); // function decleration
main()
{
char str[17];
clrscr();
scanf(“%[^n]”,str);
printf(“%s”,reverse(str));
getch();
}
// function defination reverse
char* reverse(char *p)
{
int l,i;
char ch;
for(l=0;*(p+l)!=0;l++);
for(i=0;i<l/2;i++)
{
ch=*(p+i);
*(p+i)=*(p+l1i);
*(p+l1i)=ch;
}
return(p);
}

One thought on “program to reverse the string by using pointer..

Leave a Reply

Your email address will not be published.