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

Can the “if” function be used in comparing strings?

992


What is the use of gets and puts?

988


Explain how can you determine the size of an allocated portion of memory?

1056


What’s the special use of UNIONS?

1116


Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250

1923


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

1075


What is sizeof c?

1010


Write a program to print "hello world" without using a semicolon?

1020


what is bit rate & baud rate? plz give wave forms

1922


Write a program to find the biggest number of three numbers in c?

1015


Define Array of pointers.

1055


Do pointers store the address of value or the actual value of a variable?

1031


Should I learn c before c++?

1184


What is volatile variable in c?

1059


What’s a signal? Explain what do I use signals for?

1068