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


Please Help Members By Posting Answers For Below Questions

When can you use a pointer with a function?

742


Explain how can I right-justify a string?

804


can we change the default calling convention in c if yes than how.........?

2274


What is this pointer in c plus plus?

794


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

803


How can I find out the size of a file, prior to reading it in?

871


What is a string?

851


What are the advantages of Macro over function?

1591


What is the best style for code layout in c?

824


What is integer constants?

789


Explain void pointer?

787


Why is c fast?

786


What is memcpy() function?

829


Difference between Shallow copy and Deep copy?

1770


What is wrong with this program statement?

779