Skip to content

1.5 Processing a String One Character At a Time

Ray Fix edited this page May 15, 2013 · 2 revisions

Problem

Given a string, process each character at time.

Solution

std::string str = "Hello, world.";
for (auto c : str)
{
   // process c
}

Discussion

This solution uses C++11 auto and for each.

See Also

Clone this wiki locally