When programming sometimes we need to loop through a string and deal with every character in that string. In c++ there are several ways to do that. In this post lets see 3 different ways to loop through a string.
-
Using a range-based for loop (This feature is available from c++ 11)
-
Using ierators
-
Using normal for loop
If you have a null terminated character array this method also can be used.
Those are the 4 different ways that can be used to loop through strings. If you have suggestions or new methods pleas leave a comment below.
No comments:
Post a Comment