How would I do a for loop on every character in string in C++?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Looping through the characters of a
std::string, using a range-based for loop (it’s from C++11, already supported in recent releases of GCC, clang, and the VC11 beta):Looping through the characters of a
std::stringwith iterators:Looping through the characters of a
std::stringwith an old-fashioned for-loop:Looping through the characters of a null-terminated character array: