Loading...
Engaged Employer
Write a C procedure to reverse a string in-place.
Anonymous
void reverse(char* s) { char* back = s + strlen(s) - 1; for (; s < back; ++s, --back) { char temp = *back; *back = *s; *s = temp; } }
void reverse (char* str) { char* back = str + strlen(str) - 1; while (str < back) { *str = *str ^ *back; *back = *back ^ *str; *str = *str ^ *back; str++; back--; } } balla!
since it's a very simple question, they probably wanted more optimized code, with fewer additions/subtractions.
void reverseInPlace(char * c) { char tmp; int ptr = 0; int cLen = strlen(c); for(ptr=0; ptr
Check out your Company Bowl for anonymous work chats.
Get actionable career advice tailored to you by joining more bowls.
Stay ahead in opportunities and insider tips by following your dream companies.
Get personalized job recommendations and updates by starting your searches.