08 IO库
2024-09-21 20:45:33
#include<iostream>
#include<vector>
#include<string>
#include<fstream>
using namespace std; int main()
{
ifstream in("test.txt");
if (!in)
{
cerr << "打开文件失败" << endl;
exit();
} vector<string> vec;
string str;
in >> str;
while (getline(in, str))
vec.push_back(str); for (auto c : vec)
cout << c << endl;
return ;
}
#include<iostream>
#include<vector>
#include<string>
#include<fstream>
using namespace std; int main()
{
ifstream in("test.txt");
if (!in)
{
cerr << "打开文件失败" << endl;
exit();
} vector<string> vec;
string str;
in >> str;
while (getline(in, str))
vec.push_back(str); for (auto c : vec)
cout << c << endl;
return ;
}
test.txt文件内容:
输出结果:
最新文章
- SparkContext的初始化(叔篇)——TaskScheduler的启动
- 第2章 面向对象的设计原则(SOLID):1_单一职责原则(SRP)
- java系统时间的调用和格式转换
- 【转载】理解C语言中的关键字extern
- CF 103E Buying Sets 最大权闭合子图,匹配 难度:4
- java多线程之 Executors线程池管理
- nginx gzip filter模块分析
- FtpClient的使用
- sql: DUAL
- 丢手帕问题as3版
- 编译预处理命令define
- NTP 时间同步协议
- Spring容器中Bean的生命周期
- Spring Security入门(1-12)Spring Security 的过滤器机制
- 改造断路器集群监控Hystrix Turbine实现自动注册消费者、实时监控多个服务
- PHP基础架构
- 洛谷.3809.[模板]后缀排序(后缀数组 倍增) &; 学习笔记
- google和baidu搜索命令
- java面试题:jvm
- 第8月第21天 django lbforum项目记录