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

Another version that actually reverses the string...

#include <stdio.h>

char *reverse(char *sstr, char *str, char c)
{
if (*str == '\0')
return sstr;

sstr = reverse(sstr, str+1, *(str+1));

*sstr = c;

return (sstr+1);
}

int main()
{
char str[100];

printf("Enter the string: ");
scanf("%s", str);

reverse(str, str, *(str + 0));
printf("Reversed string: %s\n", str);

return 1;
}

Is This Answer Correct ?    25 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

the question is that what you have been doing all these periods (one year gap)

2087


Explain the use of fflush() function?

1085


What is the method to save data in stack data structure type?

1087


What is build process in c?

1159


What are the 4 types of unions?

1041


A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.

1722


What is #define?

1115


What are the advantages of c preprocessor?

1262


Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.

1098


What is array in c with example?

1263


Write a program to check prime number in c programming?

1094


What are integer variable, floating-point variable and character variable?

1253


How can you determine the size of an allocated portion of memory?

1306


a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

1231


What are the data types present in c?

1163