当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 2 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 求大神指导
帖子发表于 : 2015-06-25 21:10 

注册: 2015-06-22 11:22
帖子: 6
系统: ubuntu
送出感谢: 2
接收感谢: 0 次
#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *in, *out;
char ch, infile[10], outfile[10];
printf("input the infile name:");
scanf("%s", infile);
printf("input the outfile name:");
scanf("%s", outfile);
if((in=fopen(infile, "rb")) == NULL)
{
printf("infile can not be open");
exit(0);
}
if((out=fopen(infile, "wb")) == NULL)
{
printf("outfile can not be open");
exit(0);
}
while(!feof(in))
{
ch=fgetc(in);
putchar(ch);
fputc(ch, out);
}
putchar(10);
fclose(in);
fclose(out);
return 0;
}
有两个文件 test_1(其中有内容),和test_2(空),为什么执行编译后文件test_1中的内容也没了,test_2中内容也没传过去


页首
 用户资料  
 
2 楼 
 文章标题 : Re: 求大神指导
帖子发表于 : 2015-06-26 12:39 
头像

注册: 2010-11-19 14:25
帖子: 866
地址: onetracy.com
系统: 乌班图
送出感谢: 17
接收感谢: 13
你使用w标志,那么fopen就会先清除该文件的内容.


_________________
我为什么对linux感兴趣?因为它神秘。
@raoxiaowen
程序猿的生存之道:我的个人网站
比印象笔记更好用的为知笔记
我的github
推荐一个科学上网的方式


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 2 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 0 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译