istream-iterator Questions
4
Solved
The snippet below reads three integers from std::cin; it writes two into numbers and discards the third:
std::vector<int> numbers(2);
copy_n(std::istream_iterator<int>(std::cin), 2, nu...
Oldworld asked 22/2, 2011 at 4:49
1
Solved
I have an istream and need to copy the content between two delimiters to a std::string.
I can find the delimiters' streampos, but when trying to use istream_iterator<char> to iterate over the...
December asked 17/10, 2019 at 9:8
5
The purpose of my program is to open a text file of m lines of the same length n, read the file column by column and print each column.
For example, for this text file
abcd
efgh
jklm
I would...
Cloven asked 22/10, 2018 at 10:14
2
Solved
Given a file containing the following hex code: 0B 00 00 00 00 00 20 41
I'm trying to populate an std::vector <std::uint8_t> and then checking each byte manually.
Here's the code where I ...
Thing asked 15/12, 2015 at 22:20
1
N2976 suggested adding constexpr to some spots in the standard library. It notes that iostreams are inappropriate for constexpr EXCEPT end iterators. So istream_iterator and istreambuf_iterator wer...
Marylynnmarylynne asked 19/9, 2015 at 7:54
1
Solved
Can anyone tell me why the below piece of code I wrote when compiling keeps complaining istream_iterator is not a member of std please can you tell?
Thanks guys
#include <cstdlib>
#include ...
Burch asked 7/6, 2015 at 14:18
2
Solved
I want to be able to solve problems like this: Getting std :: ifstream to handle LF, CR, and CRLF? where an istream needs to be tokenized by a complex delimiter; such that the only way to tokenize ...
Escallop asked 27/4, 2015 at 12:16
3
Solved
If I want to calculate the sum of a bunch of numbers retrieved from an std::istream, I can do the following:
// std::istream & is = ...
int total = std::accumulate(std::istream_iterator<int...
Corell asked 10/12, 2013 at 18:51
3
Solved
For copying what I read from input file to vector, I used std::copy() as recommended in Reading an std::ifstream to a vector of lines.
The problem occurs if I use:
std::copy(std::istream_iterato...
Witkowski asked 21/7, 2013 at 19:28
1
In the book “Effective STL” by Scott Meyers, there is a nice example of reading an entire text file into a std::string object:
std::string sData;
/*** Open the file for reading, binary mode ***/...
Sprawl asked 5/1, 2013 at 1:34
2
Solved
I have code like this
std::ifstream file(filename, std::ios_base::in);
if(file.good())
{
file.imbue(std::locale(std::locale(), new delimeter_tokens()));
for(auto& entry : std::istream_iterat...
Hexylresorcinol asked 1/7, 2012 at 13:39
1
Solved
the following code is not behaving like I would expect. Please help me understand how it works.
#include <algorithm>
#include <iterator>
#include <fstream>
#include <vector>...
Spagyric asked 30/3, 2012 at 22:46
3
Solved
I have constructed a minimal working example to show a problem I've encountered using STL iterators. I'm using istream_iterator to read floatss (or other types) from a std::istream:
#include <i...
Grant asked 10/5, 2011 at 17:0
8
Solved
I'm trying to code opposite action to this:
std::ostream outs; // properly initialized of course
std::set<int> my_set; // ditto
outs << my_set.size();
std::copy( my_set.begin(), my_se...
Matchboard asked 30/10, 2008 at 13:2
4
Solved
I'm writing in Microsoft Visual C++ and I'd like my program to either read from standard input or a file using the istream_iterator. Googling the internets hasn't shown how simple I think it must b...
Goodwin asked 16/12, 2009 at 2:4
1
© 2022 - 2024 — McMap. All rights reserved.