In C++ std::istream is the base class for input streams.
Questions tagged [istream]
696 questions
0
votes
2 answers
How to make sure cin opened the file properly?
I have this code :
static std :: ifstream s_inF(argv[j]);
std :: cin.rdbuf(s_inF.rdbuf());
How can I make sure it opened the file properly and there is no problem ?
I mean I would like to write something like:
static std :: ifstream…

John Oldman
- 89
- 2
- 8
0
votes
2 answers
C++ iStream, If-Else & Vectors
I have this iStream function to read in a .txt file of data in the format of:
Pink Floyd: Dark Side of the Moon
0:01:30 - Speak to Me
My function almost works perfectly.
Here are my problems that I just can't figure out.
1) It prints (outputs)…

binary101
- 1,013
- 3
- 23
- 34
0
votes
1 answer
How do I send an image stored in a stream through a socket?
How do I send an image stored using GdipSaveImageToStream(), in an IStream interface, through a socket connection?
The send() function needs a char array, but I don't know how to extract the data from IStream to a char array.
Would using memcpy() be…

Kesarion
- 2,808
- 5
- 31
- 52
0
votes
2 answers
Why does istream::operator>> accept char pointers/arrays?
char someArray[n];
std::cin >> someArray; // potential buffer overrun
I've seen code like the above numerous times on the C++ forums I frequent. Is there a good reason for this not to be treated as a compile time error? or at the very least, a…

whysoconfused
- 73
- 3
0
votes
2 answers
what is the result of incrementing an istream_iterator which is already at the end of the stream?
I've looked at the standard and didn't see an obvious answer.
suppose i've done this:
std::istream_iterator is(file);
while(is != std::istream_iterator()) {
++is;
}
now is is at the end of the stream and is equal to…

Evan Teran
- 87,561
- 32
- 179
- 238
0
votes
1 answer
Reading text files c++
i am new to c++ and i'm try to write a code that reads integers of a text file and saves each integer in different variables line by line.
I am having problems with the syntax and how to arrange the code. Basically the text file contains 4 integers…

Tobey
- 1,400
- 1
- 10
- 25
0
votes
2 answers
C++ undefined symbol
I am creating a C++ console application where I am saving and loading a vector to a file. The file I am saving and loading has a header that has the size of the vector.
Here is my code:
void loadFromFile()
{
ifstream iStream("file.ext",…

Darryl Janecek
- 399
- 4
- 9
- 25
0
votes
3 answers
Overloading >> operator for Date class in c++ causes infinite loop
I'm trying to overload the >>operator for a Date class in c++ but the it goes in infinite loop when the run goes into the first if statement, can you please help me?
//operator
istream& operator >>(istream& is,CustomDate& d){
int…

ichigo663
- 79
- 1
- 7
0
votes
1 answer
How do I use MySQL C++ Connector for storing binary data?
I have a block of binary data defined as:
void* address, size_t binarySize;
that I want to store to a MySQL database using MySQL C++ Connector.
The function setBlob() takes istream.
The question:
How can I convert from a raw void* address, size_t…

sivabudh
- 31,807
- 63
- 162
- 228
0
votes
1 answer
Unable to use istream in a cpp object and header file
Header file
#ifndef IREADER_H
#define IREADER_H
#include
class iReader {
public:
iReader();
iReader(istream *input);
iReader(const iReader& orig);
virtual ~iReader();
private:
Pixel *pixelData;
char *cData;
…

klong15
- 62
- 5
-1
votes
2 answers
Reading constant number of characters in C++
How would you read a string if it was no longer than 20 characters and could contain spaces in C++? For example I have this kind of file:
3
Namama 4 5 12
Cool 4 2 34
Not So Cool 4 2 45
I want to write it in…

Pijusn
- 11,025
- 7
- 57
- 76
-1
votes
1 answer
Operator>> overloading: "cannot bind 'std::istream {aka std::basic_istream}' lvalue to 'std::basic_istream&&'"
Here's my fraction class:
class fraction { // type definition
int num;
int denom;
ostringstream sstr;
public:
fraction(int c=0, int d=1) :
num(c), denom(d)
{ sstr = ostringstream(); }
fraction(const fraction &f) :…

Marc Miller
- 97
- 7
-1
votes
2 answers
How to read from a binary file and load the data into a 3d vector in C++?
I currently have some .bin files, each of which contains a matrix of size AxBxC. I would like to load it into a 3d vector vector>> in C++, but encountered some problems.
I tried to flatten the matrix and load it into a buffer…

Ziggy1209
- 11
- 5
-1
votes
3 answers
How to prevent the user from inputing a string in c++
Hello I'm relatively new to operator overloading, but I do believe its the answer to a problem i've been facing in almost every program I make. My goal is to overload std::cin >> int_var so that it can only accept integer inputs, and if it detects…

Cod Pod Tracks
- 17
- 2
-1
votes
1 answer
Problem extracting formatted input from an istringstream that has been set twice
Thanks for the help.
My program reads lines from stdin. The first one has a single number which determines the mode at which the program is running, and the rest contain sequences of numbers of undetermined length. The number of lines is determined…