Sunday, February 15, 2009

How t reverse a string and store it

//How t reverse a string and store it

#include
# include

main()

{

int i,m,n,count;
char str[10],rev_str[10];

printf("Enter a String :");
gets(str);

for(i=0;str[i]!='\0';i++)
{

}
m=i;
int y=0;
i=i-1;
for(i;i>=0;i--)
{
rev_str[y]=str[i];
y++;


}

for(i=0 ; i< m ;i++ )
printf("%c",rev_str[i]);

}

0 comments: