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
write a program to copy the string using switch case?
what do the 'c' and 'v' in argc and argv stand for?
Write the syntax and purpose of a switch statement in C.
Write a C program linear.c that creates a sequence of
processes with a given length. By
sequence it is meant that each created process has exactly
one child.
Let's look at some example outputs for the program.
Here the entire process sequence consists of process 18181:
Sara@dell:~/OSSS$ ./linear 1
Creating process sequence of length 1.
18181 begins the sequence.
An example for a sequence of length three:
Sara@dell:~/OSSS$ ./linear 3
Creating process sequence of length 3.
18233 begins the sequence.
18234 is child of 18233
18235 is child of 18234
........ this is coad .... BUt i could not compleate it .....:(
#include
Is that possible to store 32768 in an int data type variable?
What is openmp in c?
Differentiate between functions getch() and getche().
What is spaghetti programming?
Are c and c++ the same?
What does nil mean in c?
Which of these functions is safer to use : fgets(), gets()? Why?
What are structural members?
What is substring in c?
In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?
What is an array in c?