#include <iostream>
#include <string>
#include <cctype>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv) {
string str("some !!!!!! dsjc string");
decltype(str.size()) punct_cnt = 0;
for(auto c:str)
if(ispunct(c))
++punct_cnt;
cout<< punct_cnt << endl;
return 0;
}
统计某个字符串中的标点符号数(c++11)
最新推荐文章于 2024-04-21 21:26:55 发布