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

Write a program to check palindrome number in c programming?

1007


What is the difference between if else and switchstatement

1924


Is linux written in c?

1035


Why ca not I do something like this?

1007


What is the purpose of realloc()?

1138


What is the time and space complexities of merge sort and when is it preferred over quick sort?

1066


writ a program to compare using strcmp VIVA and viva with its output.

2008


What is self-referential structure in c programming?

1203


What is a struct c#?

1044


What does a function declared as pascal do differently?

1116


Using which language Test cases are added in .ptu file of RTRT unit testing???

4268


Differentiate between null and void pointers.

1155


Under what circumstances does a name clash occur?

1193


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

1044


Declare the structure which contains the following members and write in C list of all students who score more than 75 marks. Roll No, Name, Father Name, Age, City, Marks.

1322