.将以下字符串复制到一个明文"test. txt”的文件中:
Hairy Poter is a series of seven fantasy novels write by British author J. K. Rowling. The
novels chronicle the lives of a young wizard, Hairy Poter, and his friends Hermione Gang
er and Ron Wesley, al of whom are students at Hogwarts School of Witchcraft and Wiz
dry. The main story arc concerns Hairy’s struggle against Lord Voldemort, a dark wizard w
ho intends to become immortal, overthrow the wizard governing body known as the Minis
ry of Magic and subjugate all wizards and Mules (non-magical people)
使用File l/0的方式读取test.txt,编程实现以下功能
a)将test.txt中所有的字符逆序打印在屏幕上;
b)统计test.txt中字符e出现的次数;
关于c语言的实践活动
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- 语言-逆行者 2022-12-13 22:42关注
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<string.h> int main() { FILE* fptr; fptr = fopen("test.txt", "r"); char str[6][100]; int i,j,k,count=0; if (fptr == NULL) { printf("Error!"); } for (i = 0; i < 6; i++) { fgets(str[i], 100, fptr); } fclose(fptr); printf("逆序输出:\n"); for (i = 5; i >= 0; i--) { j = strlen(str[i]); for (k = j - 1; k >= 0; k--) { if (str[i][k] == 'e') { count++; } printf("%c", str[i][k]); } printf("\n"); } printf("\n"); printf("字符e出现的次数为:%d\n",count); return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥15 运动想象脑电信号数据集.vhdr
- ¥15 三因素重复测量数据R语句编写,不存在交互作用
- ¥15 微信会员卡等级和折扣规则
- ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
- ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
- ¥15 gdf格式的脑电数据如何处理matlab
- ¥20 重新写的代码替换了之后运行hbuliderx就这样了
- ¥100 监控抖音用户作品更新可以微信公众号提醒
- ¥15 UE5 如何可以不渲染HDRIBackdrop背景
- ¥70 2048小游戏毕设项目