#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
string s("hello world!!!");
decltype(s.size()) punct_cnt=0;
for(auto c:s)
if(ispunct(c))
++punct_cnt;
cout<<punct_cnt<<" punctuation characters in "<<s<<endl;
return 0;
}
decltype用法:http://baike.baidu.com/link?url=jA9LjLVMsOI_dHD8tTmsLfPfkFvTEVMTi4vUQZaowBe69XfQ87gPHyCd5jxGUOsbbjvehLQx0OZ_slpBayNc40SI4vhFIrQ01np9IBLhCAS