#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文件内容:

输出结果:

最新文章

  1. SparkContext的初始化(叔篇)——TaskScheduler的启动
  2. 第2章 面向对象的设计原则(SOLID):1_单一职责原则(SRP)
  3. java系统时间的调用和格式转换
  4. 【转载】理解C语言中的关键字extern
  5. CF 103E Buying Sets 最大权闭合子图,匹配 难度:4
  6. java多线程之 Executors线程池管理
  7. nginx gzip filter模块分析
  8. FtpClient的使用
  9. sql: DUAL
  10. 丢手帕问题as3版
  11. 编译预处理命令define
  12. NTP 时间同步协议
  13. Spring容器中Bean的生命周期
  14. Spring Security入门(1-12)Spring Security 的过滤器机制
  15. 改造断路器集群监控Hystrix Turbine实现自动注册消费者、实时监控多个服务
  16. PHP基础架构
  17. 洛谷.3809.[模板]后缀排序(后缀数组 倍增) &amp; 学习笔记
  18. google和baidu搜索命令
  19. java面试题:jvm
  20. 第8月第21天 django lbforum项目记录

热门文章

  1. Kafka 0.10 Coordinator概述
  2. 在 .NET Framework 4.0 的程序中使用 .NET Framework 2.0 的程序集
  3. HDU - 4901 The Romantic Hero(dp)
  4. JSON与对象的相互转换
  5. python 小程序,输错三次密码锁定账户
  6. SpringMVC学习笔记_01
  7. Linux - 网络检测
  8. 使用css将图像居中
  9. Android 中查看内存的使用情况集常用adb命令
  10. ajax大并发问题