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
Why clrscr is used after variable declaration?
Write a C program that will accept a hexadecimal number as input and then display a menu that will permit any of the following operations to be carried out: Display the hexadecimal equivalent of the one's complement. (b) Carry out a masking operation and then display the hexadecimal equivalent of the result. (c) Carry out a bit shifting operation and then display the hexadecimal equivalent of the result. (d) Exit. If the masking operation is selected, prompt the user lor the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected. prompt the user for the type of shift (left or right), and then the number of bits. Test the program with several different (hexadecimal) input values of your own choice.
Explain #pragma statements.
Can 'this' pointer by used in the constructor?
Write a C program to count the number of email on text
what is a function method?give example?
Explain pointer. What are function pointers in C?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
What is const and volatile in c?
Explain what are bus errors, memory faults, and core dumps?
Is printf a keyword?
how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.
shorting algorithmS
What is the equivalent code of the following statement in WHILE LOOP format?
What are pointers? What are different types of pointers?