Question: Reverse a string in C using as little additional memory as possible. Answer: The first solution needs the size of a char and size of two integers, all of which will be allocated from the stack. This solution is the most commonly accepted “good” solution. Here is the code. void reverseString(char* str) { int i, j; char temp; i=j=temp=0; j=strlen(str)-1; for (i=0; i
Read full article from Reverse a String » My Tech Interviews
No comments:
Post a Comment