没有 STL 容器的迭代器
Iterators without STL containers
起初对不起我的英语。 我m preparing for my exam and I need to practice iterators, that don
不使用容器。 我想在符号上输入一些符号,例如"",但我不知道该怎么做。 问题是我无法停止输入符号。 希望你能帮助我。 衷心感谢您!
#include <iostream>
#include <iterator>
#include <algorithm>
#include <fstream>
using namespace std;
int main()
{
ofstream out("name.txt");
istream_iterator<char> it(cin);
istream_iterator<char> end_of_stream;
ostream_iterator<char> fout(out, " ");
copy (it, end_of_stream, fout);
}
在获得特定值之前没有算法可以复制(我认为(,因此您必须编写自己的循环。
喜欢这个
while (it != end_of_stream && *it != 'n')
{
fout << *it;
++it;
}
相关文章:
- 自定义 STL 兼容迭代器,用于迭代 2D 数组类的列
- "迭代器"和"const_iterator"不是 STL 容器的必需成员?
- 没有 STL 容器的迭代器
- 为什么某些 STL 容器(堆栈、队列、优先级队列)不支持迭代器?
- 迭代器 STL C++是模板、类还是接口?
- 为什么我们不在 STL 的迭代器中传递星号(*)
- 成员函数不能为集合迭代器和const_iterator的输入重载(但可以为其他 STL 迭代器重载)
- 如何在C++中重新实现包含指针的 STL 容器的类的迭代器
- C++如何获取传递给函数(STL 迭代器)的参数的名称
- 迭代器和 STL 容器的关系
- C++ 中 STL 中迭代器的大小(以字节为单位)是多少
- 如何将 stl 迭代器与特征一起使用?
- 用于 STL 迭代器、指针和 std::nullptr_t 的模板函数
- 在 stl 容器包装器中定义迭代器类型
- 在多个 STL 对对象上创建迭代器
- 如何为获取 stl 容器迭代器的函数提供函数签名?
- 在 stl 算法中移动迭代器
- lower_bound 在 C++ STL 中返回迭代器,即使元素不存在也是如此.如何避免这种情况?
- 并行STL插入迭代器,例如std :: back_insert_iterator
- STL 迭代器继承:"value_type"不命名类型