The most wonderful life is not the moment to realize the dream, but to keep the dream of the process.
人生最精彩的不是实现梦想的瞬间,而是坚持梦想的过程。
题目描述:读取a.txt中文本,统计文本中字母数量。(题目只要求补充部分函数)
样例输入
abc abc
样例输出
6
源代码
代码语言:javascript复制#include<stdio.h>
#include<string.h>
extern void solve();
int main(void)
{
FILE *f=fopen("a.txt","w");
fprintf(f, "%s", "FILE *fp = fopen(a.txt,r);FILE *fpp = fopen(b.txt,w);int a,c;char s[10];");
fprintf(f, "%s", "n abc");
fclose(f);
solve();
return 0;
}
void solve(){
int n,k;//k起记数效果
char a[100];
k=0;
FILE *fp;
fp=fopen("a.txt", "r");
for (n = 0; n < 100; n ) {
if(feof(fp)){//判断文件是否结束,若结束则返回0
break;
}
fscanf(fp, "%c", &a[n]);
if(a[n]=='