问答题
请编写一个函数fun(),该函数的功能是:返回给定字符串中大写字母字符的个数。
如字符串"Hello World"中,大写字母的个数为2个。
注意:部分源程序已存在文件PROC5.CPP中。
请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句。
文件PROC5.cpp的内容如下:
//PROC5.cpp
#include<iostream>
#include<string>
using namespace std;
int fun(char *str);
int main()
char str[ ]="Chinese Computer World";
cout<<fun(str)<<end;
return 0;
int fun(char *str)
//**********
【参考答案】
下面是函数fun()函数体的一种实现:
int fun(char *str)
{
......
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)