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 do I swap bytes?

1022


What are logical errors and how does it differ from syntax errors?

1231


How can I automatically locate a programs configuration files in the same directory as the executable?

1103


Write a program which returns the first non repetitive character in the string?

1054


Compare and contrast compilers from interpreters.

1074


i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical

2276


Is there any data type in c with variable size?

1033


What does == mean in texting?

1212


What is the difference between memcpy and memmove?

968


What is memory leak in c?

1062


c program to compute AREA under integral

2336


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

2198


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

1053


Without Computer networks, Computers will be half the use. Comment.

2251


What is the main difference between calloc () and malloc ()?

1097