Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to reverse a string using a recursive function, without
swapping or using an extra memory?

Answer Posted / boomer

void Rstring( char *str,int len)
{
for(int i = 0; i < (len/2); i++)
{
str[i] ^= str[len-i-1];
str[len-i-1] ^= str[i];
str[i] ^= str[len-i-1];
}
}

int main( void )
{
char str[] = "my string";
printf("Actual string is [%s]\n", str);
Rstring(str,strlen(str));
printf("Reversed string is [%s]\n", str);

}

I dont call this swaping, coz it's not, recursive creates
new incarnations of the reverse func, EXTRA MEMORY BIG
TIME!!!

Is This Answer Correct ?    21 Yes 40 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the basis for selection of arrays or pointers as data structure in a program

4252


What is a const pointer in c?

1077


if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above

1110


What are the different types of pointers used in c language?

997


What is a program?

1188


praagnovation

2223


What is the meaning of c in c language?

1080


we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above

1106


Explain the difference between ++u and u++?

1071


By using C language input a date into it and if it is right?

1022


Describe dynamic data structure in c programming language?

1043


When is a null pointer used?

1066


What is define c?

1003


Can you tell me how to check whether a linked list is circular?

1328


Explain what is the difference between the expression '++a' and 'a++'?

1155