The algorithm is as follows:
- Count the number of spaces during the first scan of the string.
- Parse the string again from the end and for each character:
If a space is encountered, store "%20".
Else, store the character as it is in the newly shifted location.
Read full article from Replace all spaces in a string with "%20″ in c-style string ~ KodeKnight
No comments:
Post a Comment