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

How can you avoid including a header more than once?

981


Why is sprintf unsafe?

1068


Explain what are the __date__ and __time__ preprocessor commands?

1115


What is selection sort in c?

1081


What is the general form of function in c?

1020


What is a null string in c?

1033


what are the 10 different models of writing an addition program in C language?

1891


What does the c in ctime mean?

1087


How are Structure passing and returning implemented by the complier?

1162


What are the types of type specifiers?

1033


Hai what is the different types of versions and their differences

1937


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

1150


Ow can I insert or delete a line (or record) in the middle of a file?

998


What are compound statements?

1171


What is the process to generate random numbers in c programming language?

1171