(读取文件中的字符串,并输出各个单词的个数)
如果需要排序,可以在末尾排序后在输出
文件test.txt中的字符串为:Hello,welcome you to come here,luck to you!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct{
int len;
char ch[20];
}word;
void main(){
FILE *fp;
char ch,s[100],str[20];
int count=0,i=0,j=0,k;
word words[20];
if((fp=fopen("test.txt","r"))==NULL){
printf("无法打开此文件\n");
return;
}
while((ch=fgetc(fp))!=EOF) s[i++] = ch; //从文本中读取字符串
s[i]='\0';
puts

该博客介绍了如何读取文件内容,统计其中单词个数。通过示例展示了对'Hello,welcome you to come here,luck to you!'这个字符串的处理,如果需要,还可以进行排序后再输出。"
118168753,10293780,借助生肖游戏理解二进制编码与进制转换,"['计算机基础教育', '二进制', '数制转换', '教学方法', '游戏化学习']
最低0.47元/天 解锁文章
3068

被折叠的 条评论
为什么被折叠?



