How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / vishnu
Try this ...
#include <stdio.h>
#include <stdlib.h>
int Rev (char *s, char *b)
{
int i ;
char c ;
if (*s == '\0')
{
return 0 ;
}
c = *s ;
i = Rev (s + 1, b) ;
b[i] = c ;
return i+1 ;
}
int main ()
{
int end ;
char str[] = "Billie jean is not my lover - MJ" ;
end = Rev (str, str) ;
str[end] = '\0' ;
printf ("Now [%s]\n", str) ;
exit (0) ;
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What are keywords c?
What is wrong with this declaration?
How to delete a node from linked list w/o using collectons?
What are the types of variables in c?
What is a program flowchart?
What is the size of array float a(10)?
Explain what is a pragma?
How can I read in an object file and jump to locations in it?
What is wrong with this initialization?
What is calloc in c?
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
How is pointer initialized in c?
write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...
Difference between goto, long jmp() and setjmp()?
What is .obj file in c?