问答题

【参考答案】

如果用STL的话,很容易:
R.eturn count(str, str+strlen(str), ch);