2017-04-11 80 views

回答

0

使用一個循環:

for (char c : s) 
{ 
    std::cout << "Character '" << c << "'\n"; 
} 

或者:

for (std::size_t i = 0; i != s.size(); ++i) 
{ 
    std::cout << "Character " << i << " is '" << s[i] << "'\n"; 
} 
+0

[Demo](http ://ideone.com/yWngGE) –

+1

考慮'std :: transform',你甚至可以使用'deal'作爲'UnaryOperation'。 – luk32