- Reverse String in C - GeeksforGeeks
In this article, we will learn how to reverse string in C The most straightforward method to reverse string is by using two pointers to swap the corresponding characters starting from beginning and the end while moving the indexes towards each other till they meet each other
- Explain this C code to reverse a string - Stack Overflow
The basic idea behind this code is to work in two passes: In the first pass, we end up with a pointer to the last character to the string In the second pass, we turn the string around, assisted by the knowledge of where the string ends This first pass is given by the following logic: char *end = str; while (*end) { ++end; } --end;
|