| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 633 人关注过本帖
标题:[讨论]大家来看一下:一个非常奇怪的问题
只看楼主 加入收藏
笑红尘
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2004-11-20
收藏
 问题点数:0 回复次数:4 
[讨论]大家来看一下:一个非常奇怪的问题

#include <stdio.h> #include <stdlib.h> void main(int argc,char*argv[]) { FILE *fp1,*fp2; char c,ch; long j; char *in_file,*out_file; if(argc!=3) { printf("\ninput the in_file:"); gets(in_file); printf("\ninput the out_file"); gets(out_file); } else { strcpy(in_file,argv[1]); strcpy(out_file,argv[2]); }

if(!(fp1=fopen(in_file,"rb"))) {printf("\ncannot open the in_file"); exit(1); } fp2=fopen(out_file,"wb"); if(!fp2) { printf("\ncannot open the out_file"); exit(1); } printf("\ninput the passwd:"); scanf("%i",&j); srand(j); /*初始化随机函数生成器*/ ch=fgetc(fp1); while(!feof(fp1)) { c=rand(); ch=ch^c; fputc(ch,fp2); ch=fgetc(fp1); } fclose(fp1); fclose(fp2); printf("\nlock file successfully!"); exit(0); } 编译运行时,说“cannot open the out_file” 可如果要加入两个没有什么作用的输出语句就可以拉 比如:

[此贴子已经被作者于2005-3-31 13:31:35编辑过]

搜索更多相关主题的帖子: include 
2005-03-31 13:30
笑红尘
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2004-11-20
收藏
得分:0 

#include <stdio.h> #include <stdlib.h> void main(int argc,char*argv[]) { FILE *fp1,*fp2; char c,ch; long j; char *in_file,*out_file; if(argc!=3) { printf("\ninput the in_file:"); gets(in_file); /*********在这加一个getch() 也能运行*******************/ printf("\ninput the out_file"); gets(out_file); } else { strcpy(in_file,argv[1]); strcpy(out_file,argv[2]); }

printf("\nin_file is %s",in_file); /***** 加入这两句就可以拉*************/ printf("\nout_file is %s",out_file); if(!(fp1=fopen(in_file,"rb"))) {printf("\ncannot open the in_file"); exit(1); } fp2=fopen(out_file,"wb"); if(!fp2) { printf("\ncannot open the out_file"); exit(1); } printf("\ninput the passwd:"); scanf("%i",&j); srand(j); /*初始化随机函数生成器*/ ch=fgetc(fp1); while(!feof(fp1)) { c=rand(); ch=ch^c; fputc(ch,fp2); ch=fgetc(fp1); } fclose(fp1); fclose(fp2); printf("\nlock file successfully!"); exit(0); } 请问这时怎么回事?

[此贴子已经被作者于2005-3-31 13:35:00编辑过]


2005-03-31 13:33
ysf996
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-3-28
收藏
得分:0 
可以运行啊  我怎么可以运行呢?
2005-03-31 19:13
空前
Rank: 1
等 级:新手上路
帖 子:1146
专家分:0
注 册:2004-5-11
收藏
得分:0 

#include <stdio.h> #include <stdlib.h> void main(int argc,char*argv[]) { FILE *fp1,*fp2; char c,ch; long j; char *in_file,*out_file; if(argc!=3) { printf("\ninput the in_file:"); gets(in_file); printf("\ninput the out_file"); gets(out_file); } else { strcpy(in_file,argv[1]); strcpy(out_file,argv[2]); }

if(!(fp1=fopen(in_file,"rb"))) {printf("\ncannot open the in_file"); exit(1); } fp2=fopen(out_file,"wb"); if(!fp2) { printf("\ncannot open the out_file"); exit(1); } printf("\ninput the passwd:"); scanf("%i",&j); srand(j); /*初始化随机函数生成器*/ ch=fgetc(fp1); while(!feof(fp1)) { c=rand(); ch=ch^c; fputc(ch,fp2); ch=fgetc(fp1); } fclose(fp1); fclose(fp2); printf("\nlock file successfully!"); exit(0); } 指针只能赋值,不能用那个函数!


2005-03-31 19:26
笑红尘
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2004-11-20
收藏
得分:0 
斑竹的不是和我的一样吗
你能给我解释一下 为什么 我加个输出语句就可以运行了
我以前从来没碰到国这种情况

2005-04-01 00:13
快速回复:[讨论]大家来看一下:一个非常奇怪的问题
数据加载中...
 
   



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

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