In this quick article, we’ll explore how to reverse a C-String, which is a null-terminated ('\0') block of a contiguous sequence of characters.

The standard solution is to loop through the first half of the given C-string using a loop and swap the current character with the corresponding character on the other half of the C-string. We can do this in the following ways:

1. Using simple for-loop

Download  Run Code

2. Using pointers arithmetic

Download  Run Code

3. Using XOR operator

Download  Run Code

That’s all about reversing a C-String.