To loop over each character in a string named myString, one could use for(_______ : myString). 

  • auto& ch 
  • char& ch 
  • int i 
  • string str
Using auto& ch in a range-based for loop allows iterating over each character directly without copying. The auto keyword infers the type, making the code cleaner.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *