Questions tagged [istream]

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

696 questions
0
votes
2 answers

IStream to MSXML DOMDocument

Is there a simple way for me to take an IStream of an XML document and then load it in to an IXMLDOMDocument (msxml)? Preferably without writing the stream to disk.
evve
  • 2,806
  • 2
  • 14
  • 11
0
votes
1 answer

How to ignore \n for istream strings

Does anyone have any suggestions on how I can ignore the "\n" coming in from istream? I'm trying to extract data from txt file where in some "cells", text has been written in such that there are "\n" coming in from when the user pressed Enter. My…
ktosayev
  • 17
  • 5
0
votes
4 answers

Overloading operator>> to a char buffer in C++ - can I tell the stream length?

I'm on a custom C++ crash course. I've known the basics for many years, but I'm currently trying to refresh my memory and learn more. To that end, as my second task (after writing a stack class based on linked lists), I'm writing my own string…
exscape
  • 2,185
  • 4
  • 21
  • 25
0
votes
0 answers

Getting ifstream from istream and calling functions via overloaded >> operator

I've created an object, PDBParser, to extract information from a PDB file. Now I am trying to overload the >> and << operators so that I can use them from the main as so: inFile >> MyPDBParser; outfile << MyPDBParser; I've got the << operator all…
0
votes
2 answers

What is a better way to read a file until it ends than using istream eof?

I have read that using istream eof is "buggy" and not a "formal" way of writing code, so what is a better code to use? For example, I have the following code: using namespace std; //I've heard this is bad practice also int main(){ string line; …
user1655752
  • 45
  • 1
  • 5
0
votes
1 answer

istream Unhandled exception, stack overflow

I'm fairly new to C++, and am trying to get the istream to work. I have a class of: class rat { private: int num; int denom; public: rat(); rat(const int&, const int&); rat(const int&); friend ostream& operator <<…
Wincruzer
  • 3
  • 1
0
votes
3 answers

Remove whitespace from input stream by only means of istream functions

Is there any way of to remove the trailing whitespace after entered a decimal? E.g.: 10 A I want to catch the first character after the whitespace ends. (Which gotta be \n to be true. if not, then false My attempt so far: cout << "Please…
user2180833
  • 156
  • 2
  • 11
0
votes
1 answer

Can I shorten this istream function?

friend istream& operator>>(istream &is, Complex &c) { int re; int im; is >> re >> im; c.setReal(re); c.setImaginary(im); return is; } Is there any way I could do this is one or two lines? Maybe something like, is >>…
0
votes
1 answer

Cin parameters to a custom class

I have made a custom class, Person, which holds information about persons, from a job perspective. class Person { char* _name; char* _lName; char* _department; int _age, _salary; public: Person(char* name, char* lName, char*…
Nattfrosten
  • 1,999
  • 4
  • 16
  • 21
0
votes
1 answer

How to use std::istream correctly

I want to do the following: // I want 'is' to be either opened file or stringstream ... void ParseTokens(const std::istream &is, std::vector &vToks) { char ch; ... is >> ch; ... } The compiler complains: error: ambiguous…
slashmais
  • 7,069
  • 9
  • 54
  • 80
0
votes
1 answer

Get exact size of IPv6 header including the extenstion headers

If IPv4 is in question and I want to extract IP and ICMP header out of std::istream, first I get the initial 20 bytes, then check if the header lenght provided in the IPv4 header is larger than 20 bytes in order to extract any options. The next…
Marcus Frenkel
  • 691
  • 10
  • 19
0
votes
1 answer

c++ declaring a function with ostream in class header

I am having problems declaring a class function from the header file, am not sure how it should be formatted in the header. The purpose of this is to save class object data into a file, to be able to read back in later. employee.h void…
josh conners
  • 25
  • 2
  • 4
0
votes
1 answer

istream overload not working

AS REQUESTED, ACTUAL FILES: d_date.h http://pastebin.com/AFe4XE2c d_except.h http://pastebin.com/8QE2m8ia d_date.cpp http://pastebin.com/dgpxLWKv input.dat http://pastebin.com/XUpRcu9E I did a bare bones program similar to the following one, and I…
user963070
  • 629
  • 2
  • 19
  • 24
0
votes
1 answer

Cannot extract data from command line as expected

I have a courses0.dat file with a single 4 on line 1 that I want to extract with my ifstream program: void processEnrollments (std::istream& courseFile); int main (int argc, char** argv) { // Take input and output file names from the command…
user1205371
0
votes
1 answer

How to extract data after passing istream var to a function

I am currently running a command line input program for class that extracts data from the command line argument, sticks it in an ifstream then passes it by reference to a function wherein I must extract information from the file. First, I understand…
user1205371