Questions tagged [istream]

In C++ std::istream is the base class for input streams.

696 questions
4
votes
1 answer

copying from a std::istreambuf_iterator<> to a std::vector<>

I have a Visual Studio 2008 C++ application where I would like to treat a stream as a set of iterators. For example, if I were to receive an array of WIN32_FIND_DATA structures over the stream, I would like to be able to do something like…
PaulH
  • 7,759
  • 8
  • 66
  • 143
4
votes
2 answers

How to create C++ istringstream from a char array with null(0) characters?

I have a char array which contains null characters at random locations. I tried to create an iStringStream using this array (encodedData_arr) as below, I use this iStringStream to insert binary data(imagedata of Iplimage) to a MySQL database blob…
Morpheus
  • 1,722
  • 5
  • 27
  • 38
4
votes
1 answer

How could I redirect stdin (istream) in wxWidgets?

I'm trying to figure out how to redirect istream to wxwidgets. I was able to accomplish redirecting ostream, here's how (so you know what I mean): wxTextCtrl* stdoutctrl = new wxTextCtrl(...); wxStreamToTextRedirector redirect(stdoutctrl);…
Anthony
  • 225
  • 1
  • 2
  • 6
4
votes
1 answer

Windows IStream interface on std::istream

Within C++ on Windows, is there any easy way to create a (COM) IStream interface to an existing std::stream object? An example would be to read an image with IWICStream::InitializeFromIStream() from std::cin.
Hugues
  • 2,865
  • 1
  • 27
  • 39
4
votes
1 answer

Why is failbit() set?

Create a file and fill it up with zeroes: dd if=/dev/zero of=/tmp/zeroes count=1 Write this little program to extract the first unsigned integer it encounters in the file. #include #include int main() { std::ifstream…
qdii
  • 12,505
  • 10
  • 59
  • 116
4
votes
3 answers

Is it possible to use insertion operator on two objects at same time?

For example if i want to use extraction operator on two object to send the same data tto two object for syntax shortcut (out_file, cout) << "\n\nTotal tokens found: " << statistics[0] << "\n\nAlphaNumeric Tokens: " << statistics[1] …
Kelvin
  • 233
  • 1
  • 4
  • 13
4
votes
1 answer

C++ istream tellg()/fail() on eof: behavior change; work-around?

I upgraded my compiler from gcc-4.4 to gcc-4.8 and one project fails miserably stemming from the following (false) assumptions: #include #include int main() { using namespace std; istringstream iScan; int num; …
JimB
  • 971
  • 8
  • 20
4
votes
1 answer

Can I read in binary data with istream in c++?

Right now I am using istream to read in data. I have both text which I would like to read in as strings and numbers, and hashes which are read into character arrays. Since hashes are effectively random, I am hitting snags when I try to read it…
Eric Kulcyk
  • 279
  • 3
  • 15
4
votes
2 answers

Passing istream into a function

I am making a game-type program similar to the idea of pokemon. We have a tournament class that keeps track of several teams(its own class) which consists of pets(its own class) with different kinds of pets being subclasses of CPet. We are…
Nagilum
  • 65
  • 1
  • 1
  • 5
3
votes
2 answers

Error while Overloading the '>>' operator

I'm designing a Money object for a project. I'm not asking for help on implementation, because I really have to figure that out myself, but I'm getting the following error (and this is the only error!) error C2678: binary '>>' : no operator found…
Tasuret
  • 155
  • 1
  • 5
3
votes
1 answer

C++: strange behavior with std::istream or sentry wrap around

This small custom getline function was given as an answer to a question about handling different line endings. The function worked great until it was edited 2 days ago to make it not skip leading white spaces for each line. However, after the…
Tech_Guy
  • 53
  • 4
3
votes
2 answers

eof of istream in C++

bool ios::eof ( ) const; According to the library, The function returns true if the eofbit stream's error flag has been set by a previous i/o operation. This flag is set by all standard input operations when the End Of File is reached in the…
Alcott
  • 17,905
  • 32
  • 116
  • 173
3
votes
0 answers

Creating icon stream from resource file?

Win32 MFC I can load an icon stream (to use with WebView2) from a physical ICO file on my hard drive. Eg: wil::com_ptr iconStreamPdfSettings; CHECK_FAILURE(SHCreateStreamOnFileEx( L"d:\\Icons\\settings.ico", STGM_READ,…
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
3
votes
1 answer

Reading text fields from file with custom separator

I am working on a problem for a class I'm taking in which we need to read in text from a file to a 2d table of strings (called 'string table[][]'). The text file I'm reading in is formatted as follows: Ain el Beida # - # - # OEB # Algeria # Africa…
Paul Woidke
  • 928
  • 4
  • 18
  • 40
3
votes
3 answers

stringstream operator>> fails to assign a number in debug

I have this simple function that, given a string str, if it is a number then return 'true' and overwrite the reference input num. template bool toNumber(string str, T& num) { bool bRet = false; if(str.length() > 0U) { …
GiaMat45
  • 55
  • 7