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 / right

char* reverseStringR(char* string){
if(string[0] && !string[1])
return string;

char first = string[0];

reverseStringR(string+1);
size_t length_rest = strlen(string+1);
memmove(string, string+1, length_rest);
string[length_rest] = first;

return string;
}

Is This Answer Correct ?    3 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why should I use standard library functions instead of writing my own?

1274


Does c have function or method?

1007


Why is c so popular?

1165


What is #include stdlib h?

1107


What is an lvalue in c?

1130


What is advantage of pointer in c?

1193


What is substring in c?

1209


How would you use the functions fseek(), freed(), fwrite() and ftell()?

1166


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3250


Is c++ based on c?

1075


Why c is a procedural language?

1069


What does == mean in texting?

1312


What does %c do in c?

996


Is c is a procedural language?

1099


What is c language used for?

988