C语言 函数isupper怎么用?

来源:百度知道 编辑:UC知道 时间:2024/06/24 17:38:16
我想计算一篇文章有多少个大写字母,能不能给我一个例子?

#include <stdio.h>
#include <ctype.h>
main()
{
int upper_count = 0;
int i;
int ch;
while((ch = getchar()) != EOF)
{
if(isupper(ch))
upper_count++;
}
printf("upper_count == %d\n", upper_count);
return 0;
}
用标准输入重定向把文章输入程序即可

#include<stdio.h>
main()
{
FILE *fp1;
int k=0;
char *file="",temp;
printf("input you essay:\n");
scanf("%s",file);
if((fp1=fopen(file,"r"))==NULL)
{
printf("can't open infile\n");
exit(0);
}
while(! eof(fp1))
{
fread(temp,1,1,fp1);
if(temp>=65 && temp<=90) k=k+1;
}
fclose(fp1);
}

可以参考参考

在百度上找,他是最好的网上老师