How to reverse a string using a recursive function, without
swapping or using an extra memory?
Answer Posted / right
char* reverseStringR(char* string){
if(string[0] && !string[1])
return string;
char first = string[0];
reverseStringR(string+1);
size_t length_rest = strlen(string+1);
memmove(string, string+1, length_rest);
string[length_rest] = first;
return string;
}
Is This Answer Correct ? | 3 Yes | 4 No |
Post New Answer View All Answers
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
How can I use a preprocessorif expression to ?
What is infinite loop?
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
Write a program to print numbers from 1 to 100 without using loop in c?
All technical questions
How many header files are in c?
What is the hardest programming language?
What is "Hungarian Notation"?
What is the general form of function in c?
What is the purpose of the statement: strcat (S2, S1)?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
Give differences between - new and malloc() , delete and free() ?
Why is c so popular?
What is the use of typedef in c?