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 / d g patel

/* Following code does as intended */
#include <stdio.h>

#define REVERSE_STRING(X) Rstring(X, *(X), strlen(X)-1)

void Rstring( char *str, char c, int index )
{
if( index != 0 )
Rstring( str, *(str+(strlen(str))-index),
index-1);
*(str+index) = c;
}

int main( void )
{
char str[] = "Dharmendra Patel";
printf("Actual string is [%s]\n", str);
REVERSE_STRING(str);
printf("Reversed string is [%s]\n", str);
return 0;
}

Is This Answer Correct ?    92 Yes 46 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you assign a different address to an array tag?

1209


What does the message "automatic aggregate intialization is an ansi feature" mean?

1241


What does the function toupper() do?

1188


Explain the use of fflush() function?

1129


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

1202


Is main is user defined function?

1205


What is dynamic variable in c?

1095


What is difference between Structure and Unions?

1301


How do I round numbers?

1050


WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.

2494


What functions are in conio h?

1260


What are the c keywords?

1255


What is scope of variable in c?

1085


What is the difference between ++a and a++?

1268


What is variable declaration and definition in c?

962