C++以任意一个字符为分隔符,读取一行内容,显示到控制台
2016-04-28 21:51
281 查看
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream input;
input.open("D:\\用户目录\\Desktop\\sq的部分代码.txt");
if(input.fail())
{
cout<<"打开失败"<<endl;
}
else
{
char s[10000];
while(!input.eof())
{
input.getline(s,10000,'\r\n ');
//读一行,最多读10000个字节,把读到的内容存到s这个数组里面,以【换行符】为分割标志
//input.getline(s,10000,'# ');//以【#】号为分隔符
cout<<s<<endl;
}
}
input.close();
system("pause");
return 0;
}
相关文章推荐
- c++ 数据存储
- C++面向对象(一)——类与对象
- C++ 字符串十六进制与十进制的互转
- C语言的学习
- C++新手之accumulate函数
- LeetCode 338. Counting Bits C语言
- C++委托实现(函数指针,function+bind,委托模式)
- c++ string主要的用法
- C++数据类型转换二
- C++静态成员
- C语言中int类型数的表示范围及形式
- C++学习笔记之七 复合类型---枚举
- 1005. Spell It Right (20)
- C语言宏定义用法注意事项与好处
- 回调函数
- HDU 5671 Matrix
- CUnit用法总结
- C语言模拟漏斗
- C++学习笔记之六 复合类型之共用体
- C++继承、虚函数处的面试题