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 ...
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...
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...
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...
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?
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...
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...
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...
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...
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...
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...
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?
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....
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
1 Next >
© 2022 - 2024 — McMap. All rights reserved.