| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 856 人关注过本帖
标题:编程求助:将一个文件的内容复制到另一个文件,并排除"the"单词.
只看楼主 加入收藏
dragon311
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2005-3-27
收藏
 问题点数:0 回复次数:4 
编程求助:将一个文件的内容复制到另一个文件,并排除"the"单词.
如题~~~
搜索更多相关主题的帖子: 单词 文件 排除 
2005-06-05 00:14
空前
Rank: 1
等 级:新手上路
帖 子:1146
专家分:0
注 册:2004-5-11
收藏
得分:0 
大概可以这样写:

读一个单记词到一个字符数中,然后判断,处理,再逐个写入另一个文件中?

大概流程就是这样~!

代码就不写了~!(仅供参考)

2005-06-05 15:22
cosixu
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2004-10-11
收藏
得分:0 

Option Base 1 Dim a() As String Dim b() As Variant

Private Sub Form_click() Open "e:\in.txt" For Output As #1 k$ = InputBox("请输入字符串") n = Len(k$) ReDim a(n) As String Static b(1 To 10) As String For i = 1 To n a(i) = Mid$(k$, i, 1) Next i For i = 1 To n Print Tab(1 * i); a(i); Next i i = 1: j = 1: u = 1 While j < n

If a(j) = " " Then b(u) = Mid$(k$, i, j - i) i = j + 1 j = i u = u + 1 Else j = j + 1 End If Wend b(u) = Mid$(k$, i, j + 1) c$ = InputBox("请输入字符串") Print For i = 1 To u If b(i) <> c$ Then Print #1, b(i); Spc(3); End If Next i Close #1 End Sub 我用vb写的运行通过了,你改成c语言代码就行了

2005-06-06 11:12
cosixu
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2004-10-11
收藏
得分:0 
我写的是把删除后的字符串写入另一个文件中:
也就是原文件为: the a  the b the c the d the ok
如果输入the文件中就剩a b c d ok然后再把这五个单词写入in.txt中
2005-06-06 11:16
musicml
Rank: 1
等 级:新手上路
帖 子:273
专家分:0
注 册:2005-4-2
收藏
得分:0 

/* 将一个文件的内容复制到另一个文件,并排除"the"单词 */

#include <stdio.h> #include <stdlib.h> #include <string.h>

void process_file();

void process_file() { FILE *fp_read; FILE *fp_write; char ch; char temp[20]; int ip; ip=0; if((fp_read=fopen("read.txt","r"))==NULL) { printf("can not open the file!\n"); exit(1); } if((fp_write=fopen("write.txt","w"))==NULL) { printf("can not open the file!\n"); exit(1); } while((ch=fgetc(fp_read))!=EOF) { if(ch!=' '&&ch!='\n'&&ch!='\b') temp[ip++]=ch; else { temp[ip]='\0'; if(strcmp(temp,"the")!=0) fputs(temp,fp_write); ip=0; fputc(ch,fp_write); } } if(ip>0) { temp[ip]='\0'; fputs(temp,fp_write); } }

int main() { process_file(); }


Every thing is possible.
2005-06-06 23:32
快速回复:编程求助:将一个文件的内容复制到另一个文件,并排除"the"单词. ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022374 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved