Questions tagged [istream]

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

696 questions
-1
votes
3 answers

Simple user request for filename for output and input

How can I request the user to input the filename that my program needs to read from and have it output the name with .out extension instead? Example: char fileName[256]; cout << "What is the file name that should be processed?"; cin >>…
Matt Swezey
  • 379
  • 3
  • 11
  • 27
-1
votes
2 answers

does the this stl operator >> function make magic happens?

I have a weird problem when I test C++ STL features. If I uncomment the line if(eee), my while loop never exits. I'm using vs2015 under 64-bit Windows. int i = 0; istream& mystream = data.getline(mycharstr,128); size_t mycount =…
-1
votes
1 answer

No instance of constructor std::istream_iterator

I have the following problem. I want to create a file constructor for my class. I am using std::copy algorithm and I get this kind of error: No instance of constructor std::istream_iterator ... matches the argument list error C2440:…
-1
votes
1 answer

load a file of 1's and 0's into a char** line by line

I have a file, at the end of each line there is possibly a newline: 111\n 100\n 101
imonaboat
  • 29
  • 7
-1
votes
2 answers

istream operator >> not recognising '\n' character

I am basically reading a .txt file and storing values. For example: Student- Mark Tennis It will store Mark into memory as the studentName. Now...If it is just Student- Tennis Then it will work fine and produce an error. However, if the file…
Sam Thers
  • 67
  • 3
  • 12
-1
votes
1 answer

How to dismiss characters/integers from input text from file?

I have managed to write some code that can read from a .txt file, however I want my program to only read in important data. For example, if my text file had the following data: Name= Samuel Favourite colour= Green Age= 24 Gender= Male I want my…
user4167396
  • 29
  • 1
  • 7
-1
votes
2 answers

Reading file with istream

I am working on a project which involves polymorphism and inheritance. lets assume that the hierarchy of the classes used in the project are: Media ----> Book ----> MediaRegistry and the declaration of each class are as follows: (the classes have…
manpmanp
  • 59
  • 2
  • 6
-1
votes
1 answer

Improving error processing for an istream helper class when using exceptions

I have written a class to control mandatory input on an istream, based on the original idea posted there: https://stackoverflow.com/a/14331519/3723423 . It verifies and skips mandatory formatting chars, a little bit like with scanf(), but with a…
Christophe
  • 68,716
  • 7
  • 72
  • 138
-1
votes
2 answers

\0 character in istream::getline()

What happens if a file contains a \0 character when using istream::getline()? Will be it be omitted or still assigned into a field in the string buffer?
Niklas R
  • 16,299
  • 28
  • 108
  • 203
-1
votes
2 answers

Problems regarding Overloading the input operator >> for reading text file

I have a Point2D class and i am trying to overload the input operator >> class Point2D { public: Point2D(int,int); int getX(); int getY(); void setX(int); void setY(int); double…
Computernerd
  • 7,378
  • 18
  • 66
  • 95
-1
votes
2 answers

Getting invalid initialization of reference of type 'std::istream&' from expression of type 'int'

I am trying to create a class that works with rational numbers and performing operator overloading on them. I am having issue on one part of the program, the input stream. I am supposed to take input in the format "12/8" for example, and it should…
Goose
  • 2,130
  • 10
  • 32
  • 43
-2
votes
1 answer

std::cin , unwanted behaviour. and how can I fix this?

I tried to play with some code to test overloading functions. The overloading part went well, however, I learned something about std::cin that made me feel stupid for not noticing it before! #include void read (int *var){ …
-2
votes
1 answer

Parsing text with str method of istringstream

I want to parse the following text from a file example_file.txt # Number of busStop 3 # Id Name Lat Lon 1 Cadorna 450781 76761 using the following example code: int main() { int _numberBus; ifstream file; …
some_math_guy
  • 333
  • 1
  • 8
-2
votes
1 answer

Not sure whats going wrong (string input)

writing a program for a class where we use functions to copy a list of data from an input txt file. One of my functions is to get the input for what file name they would like to search the data for. Heres my pre processor directions for my file as…
-2
votes
1 answer

in terms of design: overloading the insertion operator for a class member of type vector

Attempting to read from a source file to store person objects into a container. A person object is initialized with a random age, id and a categories vector of five assorted chars. person.hpp class person { protected : int age; // 0 - 99 …
andres
  • 301
  • 6
  • 21