Reverse a C-Style String
Description
Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)
Tips:
A C-Style String will always have a null character at the end of the string which you can not see, but it’s actually there. So in the case of “abcd”, strlen()
will return 4, which indicates the length of the string itself, while sizeof()
will return 5, the extra one space is for the \0
known as null character.
Pseudo-code
1 2 3 4 |
|
My C++ Solution
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
My Objective-C Solution
Test the Solution
1 2 3 4 5 6 7 |
|