Menu
 

program to reverse a string using ponters in c
#include<stdio.h>
void reverse(char *);
void main()
{
char str[100];
printf("enter a string:");
gets(str);
reverse(str);
printf("reversed string:%s",str);
}
void reverse(char *str)
{
char *str1,temp;
str1=str;
while(*str1!='\0')
{
str1++;
}
str1--;
while(str<str1)
{
temp=*str;
*str=*str1;
*str1=temp;
str++;
str1--;
}
}

Post a Comment

 
Top