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

Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

3023


Can you please explain the scope of static variables?

1005


What are the data types present in c?

1106


What is auto keyword in c?

1168


in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

8002


What is break statement?

1069


What is #line in c?

972


Can we change the value of #define in c?

969


What are the main characteristics of c language describe the structure of ac program?

1160


exit () is used to a) exit () terminates the execution of the program itself b) exit () terminates the execution of the loop c) exit () terminates the execution of the block d) none of the above

1086


how to construct a simulator keeping the logical boolean gates in c

2210


c program to compute AREA under integral

2348


What does typeof return in c?

1029


What is hungarian notation? Is it worthwhile?

1181


Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above

1108