c - How to reverse a string without using in-built and temporary variables -
this question has answer here:
reverse operations out temporary variable , in-built functions string reverse.
you can using xor logic this:
char* rev(char* str) { int end = strlen(str) - 1; int start = 0; while (start < end) { str[start] ^= str[end]; str[end] ^= str[start]; str[start] ^= str[end]; ++start; --end; } return str; }
Comments
Post a Comment