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
differentiate built-in functions and user – defined functions.
What is putchar() function?
Explain data types & how many data types supported by c?
How to create struct variables?
What does printf does?
What was noalias and what ever happened to it?
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
where are auto variables stored? What are the characteristics of an auto variable?
What is the benefit of using const for declaring constants?
What's the right way to use errno?
What is masking?
C language questions for civil engineering
What is a macro?
Explain what is output redirection?