How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / siva kumar
void reverse_string(char *string) {
static int start_index = 0;
static int end_index = strlen(string) - 1;
if (start_index <= end_index) {
char temp = string[end_index];
string[end_index] = string[start_index];
string[start_index] = temp;
start_index++;
end_index--;
reverse_string(string);
}
}
Is This Answer Correct ? | 11 Yes | 10 No |
Post New Answer View All Answers
When can you use a pointer with a function?
Explain how can I right-justify a string?
can we change the default calling convention in c if yes than how.........?
What is this pointer in c plus plus?
Write a program to find the biggest number of three numbers in c?
How can I find out the size of a file, prior to reading it in?
What is a string?
What are the advantages of Macro over function?
What is the best style for code layout in c?
What is integer constants?
Explain void pointer?
Why is c fast?
What is memcpy() function?
Difference between Shallow copy and Deep copy?
What is wrong with this program statement?