第二问出错,求大神帮帮忙!
来源:互联网 发布:php用函数做计算器 编辑:程序博客网 时间:2024/05/06 22:26
代码如下:
#include<stdio.h>#include<stdlib.h>#include<string.h>int main(){ FILE *in,*out; int i,count[26]={0}; char ch,str[20],replace[20],place[20]; //************************************************(第一问) if((in=fopen("file1.txt","r"))==NULL) { printf("can not open the file !\n"); exit(0); } while(!feof(in)){ ch=fgetc(in); if(ch>='a'&&ch<='z') count[ch-'a']++; else if(ch>='A'&&ch<='Z') count[ch-'A']++; } for(i=0;i<26;i++) printf("%c:%d\n",'a'+i,count[i]); //********************************************************(第二问) in=fopen("file1.txt","r"); printf("输入要替换的字符串:\n"); gets(place); printf("输入用以替换的字符串:\n"); gets(replace); if((out=fopen("file2.txt","w"))==NULL) { printf("can not open the file !\n"); exit(0); } i=0; while(!feof(in)){ while((ch=fgetc(in))!=' ') str[i++]=ch; str[i]='\0'; if(strcmp(str,place)==0) fputs(replace,out); else fputs(str,out); if(ch==' ') fputc(ch,out); } fclose(in); fclose(out); return 0;}
0 0
- 第二问出错,求大神帮帮忙!
- 求大神帮帮忙
- 关于喊话CALL的问题。求大神帮帮忙
- arrayadapter使用出错求大神解答
- 求大神们看看哪里出错了
- 使用监听器实现JAVA代码对数据库的定时操作,求大神帮帮忙!!!
- Android 如何实现圆形水纹状进度?类似360的,具体看图,求大神帮帮忙!
- SQL server安装跨语言失败咋整 求大神帮帮忙
- Qt的一个HelloWorld都出错,求大神解答,拜谢
- 关于xml的出错。新手求大神解救。
- asp连接远程服务器出错 求大神们进
- 求jsp高手帮帮忙
- 求高手帮帮忙吧!
- 求大神
- 求“评”若渴,各位帮帮忙!
- 你问我答-js初学者,有个问题,求大神指教。
- 你问我答-js初学者,有个问题,求大神指教。
- 求问!
- IOS开发 如果没有安装支付宝没有提示
- DELPHI 容器
- Reverse digits of an integer.
- 总结一下HBase各种级别的锁以及对读写的阻塞
- Ubuntu下Eclipse安装SVN插件
- 第二问出错,求大神帮帮忙!
- java线程同步
- 费第三方cdv成
- 华为机试 - 约瑟夫问题
- Palindrome Number
- 谷歌pb协议
- 在php中操作memcached缓存进行增删改查数据
- Container With Most Water
- HDU 4081 Qin Shi Huang's National Road System