Questions tagged [istream]

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

658 questions
-2
votes
1 answer

How to open file based on user input?

This code keeps giving me errors i dont know what Im doing wrong? How can I request the user to input the filename and then open that file and perform tasks with the data. Example: #include #include #include using…
user1725435
  • 11
  • 1
  • 2
  • 6
-2
votes
3 answers

C++ istream,read query , initial argument

The read function has it's first argument as pointer to an array to store the n bytes(mentioned by the second argument) in the file... The query is, if i have created 2 objects of class x.. then, x stack[2]; Assume i've filled the 2 object…
bkcpro
  • 15
  • 7
-3
votes
1 answer

Excel to C++? Won't Work, EVERY online youtube Tut works for them, they don't work for moi

read Excel w/ C++ (microsoft vis studio) See tutorial: https://www.youtube.com/watch?v=EjJY7yA5SWw Here's my code: *ifstream FILE("USE THIS FILE.xls"); // string date; string companyTicker; string companyName; int year1; int…
-3
votes
2 answers

Constructor with ostream and istream parameters

I've got a question implementing a class constructor that has istream and ostream parameters. These values are to be used within the scope of the class. I am building a game that will ask questions and I want to use the istream parameter to collect…
Drakn
  • 3
  • 2
-3
votes
1 answer

Issues converting istream to ifstream while passing std::cin into an argument

I am currently implementing a text-file based testing UI that will take mocked up user inputs from a text file (line-by-line) to simulate real user input instead of using std::cin. The issue arises when I attempt to pass std::cin into std::ifstream…
-3
votes
2 answers

Unknown cin properties

Try as I might, I cannot find any information on what cin.binary is for. similar ones, thinking bases, dec, hex, octal only seem to appear when used with cout - e.g., cout << std::hex << n;. However cout << std::binary << n; isn't valid Entering…
peedurrr
  • 187
  • 14
-3
votes
1 answer

ifstream-istream and function call

I am new to c++ and while i was working with streams i saw the following code: #include #include #include #include #include using namespace std; class Results { public: string const&…
nikos_k
  • 49
  • 1
  • 4
-3
votes
1 answer

How to read integers from a line in C++?

I want to read integers in a line from a file. For example the line is : 3/2+5-5 I think I need to use >>, but it stopped because of the characters; I also try to use other functions, but they are all for characters.
Jutta
  • 465
  • 5
  • 11
-3
votes
2 answers

Making C++ code more efficient and else if statement not working

I am trying to read in a few values from a text file, and store them in memory. This is what the file can store or look like Example 1 - A file storing the cashier's name, age and job title * Cashier Name: Bill Age: 25 Job Title: Cashier * Example…
-3
votes
1 answer

Can't understand C++ references and istream?

istream& read_hw(istream& in, vector& hw) { if(in){ hw.clear(); double x; while (in >> x) hw.push_back(x); in.clear; } return in; } Can someone please explain this code to…
-3
votes
1 answer

Why C++ compiler doesn't provide overloaded inserter & extractor functions for class?

Consider following program. #include using std::ostream; using std::cout; using std::istream; using std::cin; class three_d { int i,j,k; public: three_d(int a,int b,int c) : i(a),j(b),k(c) { } //friend…
Destructor
  • 13,235
  • 8
  • 48
  • 108
-3
votes
3 answers

Istream to string conversion with \n characters in C++

how can I convert istream to string, when my istream also includes newline characters and I don't want to escape whitespaces? Thank you.
P.N.
  • 169
  • 1
  • 12
-3
votes
1 answer

How to take istream pointer as parameter and use it in a function?

I have a function getToken, I want to pass it an istream to read from and use it. Here is given code. Please help me understand how to work with the istream pointer when passed as parameter. Token getToken(istream *br, string& lexeme){ return…
1 2 3
43
44