istream Questions

2

Solved

libjpeg can read JPEG data from a FILE* or a buffer. My data is coming from a std::istream. I could read the entire std::istream into a buffer to use with libjpeg, but I'd rather have libjpeg read ...
Tamathatamaulipas asked 13/6, 2011 at 7:40

3

Solved

I have the following implementation based on e.g. this question and answer struct membuf : std::streambuf { membuf(char* begin, char* end) { this->setg(begin, begin, end); } protected: vi...
Busse asked 28/1, 2016 at 16:0

6

Solved

So istringstream copies the contents of a string when initialised, e.g string moo("one two three four"); istringstream iss(moo.c_str()); I was wondering if there's a way to make std::istringstre...
Gibert asked 26/6, 2010 at 5:59

6

Solved

I have a bunch of input files that look like the following: (8,7,15) (0,0,1) (0,3,2) (0,6,3) (1,0,4) (1,1,5) I need to write a function that parses these inputs one number at a time, so I need t...
Coquelicot asked 19/8, 2011 at 6:5

2

I am reading Bjarne Stroustrup's "Programming Principles and Practice Using C++" (second edition). On page 660-661, the writers define a function as follows: istream& read_word(istrea...
Chaney asked 13/7, 2022 at 5:24

6

Solved

I'm sure I've just missed this in the manual, but how do you determine the size of a file (in bytes) using C++'s istream class from the fstream header?
Reggi asked 9/3, 2010 at 14:0

5

Solved

I have the following piece of code that prompts the user for their cat's age and name: #include <iostream> #include <string> int main() { int age; std::string name; std::cin >&g...
Evanescent asked 5/2, 2014 at 2:1

5

Solved

At 50:40 of http://channel9.msdn.com/Events/GoingNative/2013/Writing-Quick-Code-in-Cpp-Quickly Andrei Alexandrescu makes a joke about how not efficient/slow istream is. I had an issue in the...
Crockery asked 8/9, 2013 at 21:21

1

Solved

Apparently, C++20 has a new std::istream-related construct: std::istream_view. The cppreference page on it is a stub right now†. So, what is a "view of an istream" and what can I use it f...
Rick asked 11/12, 2020 at 22:32

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

7

Solved

I have a char* and the data length that I'm receiving from a library, and I need to pass the data to a function that takes an istream. I know I can create a stringstream but that will copy all the...
Vidavidal asked 16/10, 2011 at 2:8

3

Currently I have a program that reads from the standard input, occasionally the program needs to just keep running if no input is made, usually this is a test script there is no 'enter' so to speak...
Swerve asked 16/5, 2013 at 16:4

1

Solved

I'm trying to set the internal buffer of an input stream, but my implementation in C++17 doesn't implement pubsetbuf() for istringstream. I've tried some other techniques, but they are slow or cop...
Kick asked 23/5, 2019 at 21:49

4

I have encountered code which does this: SomeObject parse (std::istream && input) {.... The input argument is an rvalue reference, which normally means the function is intended to take o...
Inter asked 16/1, 2019 at 15:56

2

Solved

When using scanf() and its variants, the format specifier %i will accept data as hex (prefixed "0x"), octal (prefixed "0"), or decimal (no prefix), so for example the strings "0x10", "020", and "16...
Nadaba asked 18/12, 2010 at 5:27

2

Why is there no template <typename T> T std::from_string(const std::string& s); in the C++ standard? (Seeing how there's an std::to_string() function, I mean.) PS - If you have an ide...
Beaded asked 26/8, 2016 at 15:2

2

My problem is something like I want to append some string in front of a iostream. You can say in front of std::cin. #include <iostream> #include <string> void print(std::istream &...
Messuage asked 20/3, 2018 at 23:7

1

Many sites describe the istream::putback() function that lets you "put back" a character into the input stream so you can read it again in a subsequent reading operation. What's to stop me, howeve...
Hyp asked 25/3, 2016 at 3:46

5

#include <iostream> #include <string> using namespace std; int main() { string username; cout<< "username" ; cin >> username; } So I was curious on what's the differ...
Utilitarianism asked 2/5, 2015 at 16:58

3

Solved

How to input from stream to enum type? I can do it so unsigned int sex = 0; stream >> sex; student.m_bio.sex = static_cast<Sex>(sex); Otherwise?
Divestiture asked 12/4, 2011 at 10:28

1

I am implementing a shell-like program in C++. It has a loop that reads from cin, forks, and waits for the child. This works fine if the input is interactive or if it's piped from another program....
Softhearted asked 5/12, 2016 at 0:59

6

Solved

I want to have a variable of type istream which can hold either the contents of a file or a string. The idea is that if no file was specified, the variable of type istream would be assigned with a ...
Abundance asked 5/8, 2016 at 21:42

2

Solved

The below function part of connector/C++, it returns a istream*. if i just try and print it, it shows hex or a memory location because its a * type. istream *stream = res->getBlob(1); I tried...
Jennettejenni asked 5/9, 2013 at 0:34

1

Solved

I'm trying to read as many std::complex<double> as possible from a file (or any std::istream). If the operation fails, I check for ios::eof(). If it hasn't been set, I assume that there was a...
Jacquetta asked 16/6, 2016 at 12:45

2

Solved

I have mocked virtual method returning istream&. I'd like to use it in a testcase. How to return some value? The problem is that istream is noncopyable. I try something like this: TEST(x, y)...
Gryphon asked 30/3, 2016 at 11:51

© 2022 - 2024 — McMap. All rights reserved.