How it works...

We will be prompted to enter a string that will be assigned to the str variable. A string is nothing but a character array. Assuming we enter the name manish, each character of the name will be assigned to a location in the array one by one (see Figure 5.4). We can see that the first character of the string, the letter m, is assigned to the str[0] location, followed by the second string character being assigned to the str[1] location, and so on. The null character, as usual, is at the end of the string, as shown in the following diagram:

Figure 5.4

To reverse the string, we will seek the help of two pointers: one will be set ...

Get Practical C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.