找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 575|回复: 9

[求助]fstream 的输出输入目录在哪???

[复制链接]
发表于 2009-11-2 04:55:13 | 显示全部楼层 |阅读模式 IP:江苏扬州
cout<<"Entert the name of the input file:";
string inputFileName;
getline(cin,inputFileName);
ifstream inStream;
inStream.open(inputFileName.data());
assert(inStream.is_open());




cout<<"Enter the name of the output file:";
string outputFileName;
getline(cin,outputFileName);

ofstream outStream(outputFileName.data());
assert( outStream.is_open() );



例如我要读入 1 2 3 4 5 6
该在哪创建一个inputName? 和输出名字 outputFileName?
VC6.0
发表于 2009-11-2 04:55:18 | 显示全部楼层 IP:江苏扬州
当前目录,就是你的工程目录
回复

使用道具 举报

发表于 2009-11-2 04:55:22 | 显示全部楼层 IP:江苏扬州
以下是引用maoguoqing在2007-8-22 14:12:43的发言:

当前目录,就是你的工程目录
刚刚学到,不懂啊
书上没流程。。。。
回复

使用道具 举报

发表于 2009-11-2 04:55:27 | 显示全部楼层 IP:江苏扬州
你的源文件保存的地方
回复

使用道具 举报

发表于 2009-11-2 04:55:32 | 显示全部楼层 IP:江苏扬州
以下是引用maoguoqing在2007-8-22 17:19:05的发言:
你的源文件保存的地方
怎么还是读取不到的,晕。
保存源文件的几个文件夹都放过,
文件是: test.dat 读取时也是test.dat
怎么不行啊 晕。
回复

使用道具 举报

发表于 2009-11-2 04:55:36 | 显示全部楼层 IP:江苏扬州
那用inputFileName.c_str()式一下
回复

使用道具 举报

发表于 2009-11-2 04:55:41 | 显示全部楼层 IP:江苏扬州
不行啊,是不是我用的格式不对啊?
我用写字板写数字上去的,然后就改文件名
回复

使用道具 举报

发表于 2009-11-2 04:55:47 | 显示全部楼层 IP:江苏扬州
你把完整的代码贴上来吧
回复

使用道具 举报

发表于 2009-11-2 04:55:55 | 显示全部楼层 IP:江苏扬州
include<fstream>
#include<iostream>
#include<string>
#include<cassert>
#include<cfloat>
using namespace std;
int main()
{
cout<<" This program computes the number, maximum,minimum,and\n"
<<"average of an input list of numbers in one file,\n"
<<"and places its results in another file.\n\n";
//--------------------------输入部分----------------------------
cout<<"Entert the name of the input file:";
string inputFileName;
getline(cin,inputFileName);
ifstream inStream;
inStream.open(inputFileName.data());
assert(inStream.is_open());
int count=0;
double reading,
maximum=DBL_MIN,
minimum=DBL_MAX,
sum=0;
for(;;){
inStream>>reading;
if( inStream.eof() )
break;
count++;
sum+=reading;
if (reading<minimum)
minimum=reading;
if(reading>maximum)
maximum=reading;
}
inStream.close();
//-------------------------------------------
cout<<"Enter the name of the output file:";
string outputFileName;
getline(cin,outputFileName);
ofstream outStream;
outStream.open(outputFileName.data());
assert( outStream.is_open() );
outStream<<"\n-->There were"<<count<<"values";
if(count>0)
outStream<<"\n\tranging from"<<minimum
<<" to "<<maximum
<<"\n\tand their average is " <<sum/count
<<endl;
outStream.close();
cout<<"processing complete.\n";
return 0;
}
回复

使用道具 举报

发表于 2009-11-2 04:55:59 | 显示全部楼层 IP:江苏扬州
只是读取不到要打开的文件
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 03:27 , Processed in 0.201251 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表