New Android apps UniqueKey

Friday 20 February 2015

Reverse the string without library function


#include<stdio.h>
#include<string.h>

main()
{
 char str[50];
 int i,j,len,temp;
 
 printf("enter the string\n");
 gets(str);
 
 len=strlen(str);
 
 for(i=0,j=len-1;i<=len/2;i++,j--)
 {
  temp=str[i];
  str[i]=str[j];
  str[j]=temp;
 }
 
 printf("reversed string is : %s\n",str);
 
}

No comments:

Post a Comment