BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #32932同步于 2009/12/7
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

C++文件的输入输出问题

sguo
2009/12/7镜像同步10 回复
编译程序有错: No such file or directory. #include<iostream> #include<fstream> #include<stdlib> using namespace std; #define FILE_IN "D:\\in.txt" #define FILE_OUT "D:\\out.txt" int main() { ifstream input; ofstream output; input.open(FILE_IN); if(!input) { cout<<"无法找到输入文件"<<FILE_IN; cout<<"\n退出程序,再见!\n"; exit(1); } output.open(FILE_OUT); char data[25],station[50]; int high,low; float humidity,rain; input.getline(data,25); input.getline(station,50); input>>high>>low>>humidity>>rain; //输出 output<<"日期:"<< data << endl; output<<"气象站:" << station << endl; if(rain == 0.0) output << "无雨" ; else output << "有雨" ; int range; range = high-low; output << "\n温度范围是" << range; input.close(); output.close(); return 0; } 其中in.txt和out.txt均直接放在D盘下, in.txt文件内容为 September 13,2001 American LosAngels 83 60 0.18 0.00
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
jmpesp机器人#1 · 2009/12/7
DarkIce机器人#2 · 2009/12/7
#include<stdlib> 少个.h吧 【 在 sguo (异想天空) 的大作中提到: 】 : 编译程序有错: No such file or directory. : #include<iostream> : #include<fstream> : ...................
Wing机器人#3 · 2009/12/7
我相信编译器有说No such file or directory指的是stdlib这个头文件,请改为stdlib.h试试......
sguo机器人#4 · 2009/12/7
恩恩,确实!!#include<stdlib.h>编译通过~~~~~~多谢楼上2位大牛!!
jmpesp机器人#5 · 2009/12/7
【 在 sguo 的大作中提到: 】 : 恩恩,确实!!#include<stdlib.h>编译通过~~~~~~多谢楼上2位大牛!! 我帮他们说 不客气[em21]
winton机器人#6 · 2009/12/7
... 【 在 sguo (异想天空) 的大作中提到: 】 : 恩恩,确实!!#include<stdlib.h>编译通过~~~~~~多谢楼上2位大牛!!
hj001机器人#7 · 2009/12/7
【 在 jmpesp 的大作中提到: 】 : 我帮他们说 不客气[em21] 呃
ericyosho机器人#8 · 2009/12/7
如果原来在C语言里面使用以下格式: #include <xxx.h> 那么请在C++编译器里,使用: #include <cxxx> 所以#include <cstdlib>
coolwc机器人#9 · 2009/12/8
re 我有时候看到帖子里贴出来的代码不符合c++代码习惯 我就会难受 忍不住要重写一下 强迫症真痛苦 【 在 ericyosho 的大作中提到: 】 : 如果原来在C语言里面使用以下格式: : #include <xxx.h> : 那么请在C++编译器里,使用: : ...................