编写一个函数
编写一个函数, 该函数返回给定字符串中大写字母字符的个数。例如:字符串“Chinese Computer World”中,大写字母字符的个数是3个。写出主函数,设计几个字符串,测试函数输出结果是否正确。函数首部参数要求用指向字符的指针,比如 int Fun(char *str);
#include #include #include int GetCapitalNumber(char * pcIn) { char *pcTmp = pcIn; int iCount = 0; while(1) { if(*pcTmp == 0) break; if(*pcTmp>= 'A' && *pcTmp <= 'Z') iCount++; pcTmp++; } return iCount; } int main(void) { char strTemp[3][100] = {0}; int i, n; strcpy(strTemp[0], "Chinese Computer World"); strcpy(strTemp[1], "TEST1"); strcpy(strTemp[2], "test2"); for(i=0; i<3; i++) { n = GetCapitalNumber(strTemp[i]); printf("Test String No。
%d: %s\n", i, strTemp[i]); printf("Number of capital letter is %d\n\n", n); } system("pause"); return 0; } 。
答:下面是一个包括函数在内的完整代码,请LZ参考: #include char *mystrspc(char *string,int n) { int i; fo...详情>>