Questions tagged [istringstream]

Anything related to C++ `istringstream` standard library class. This class represents an "input string stream", i.e. an input stream that allows a string to be used as the source of information attached to the stream.

Anything related to C++ istringstream standard library class. This class represents an input string stream, i.e. an input stream that allows a string to be used as the source of information attached to the stream.

istringstream is a specialization of the basic_istringstream template class and it is defined in C++ <sstream> standard library header.

See CPPreference.com on basic_istringstream template class.

216 questions
0
votes
1 answer

ifstream, getline, and istringstream slow performance on big file in c++

I want to ask about my code below: (The code below basically read an input file named inputVelocity.dat with format stated in the code. The code reads with istringstream to pass each value to each particular arrays) std::ifstream…
mfakhrusy
  • 1,128
  • 1
  • 11
  • 20
0
votes
2 answers

Analogous network protocol for transmitting messages using istream/ostream

This was a question from a coding challenge and I couldn't figure out the way to do it - Implement encode() and decode() for a simple wire protocol per the prototypes below: void encode ( const std::string& inputFilename, std::ostream& out ); void…
quantumshiv
  • 97
  • 10
0
votes
1 answer

C++ reading from stdin using istringstream

Im trying to call different functions from keyboard but I've faced a few problems due to my lack of knowledge/experience with cin,istringstream etc.Here is my simplified code : #include #include using namespace std; int…
Alex R.
  • 459
  • 5
  • 16
0
votes
2 answers

Why does cleaning istringstream fail?

While converting a string to integer I just fail to clear my istringstream to place in another number. I have tried all kinds of different solutions but it just wont work. There are a few work arounds but I'd like to learn to know why... So…
Johnnie W
  • 127
  • 1
  • 1
  • 9
0
votes
1 answer

How to read doubles from a string in c++ using istringstream

I am new to programming c++. I am trying to read 75 doubles that are inside of a string that I read from a file. I am trying to use istringstream. This is what I have so far: Header File: #ifndef READPOINTS_H_INCLUDE #define…
Kyle
  • 43
  • 1
  • 6
0
votes
1 answer

about istringstream and >>operator

string str = "0.000 0.005 0.001"; istringstream s(str); string sub; while (s) { s >> sub; cout << sub << endl; } That is my code, I just want to output every number in str, but I get the last number twice. I know there are many better ways…
何向旋
  • 5
  • 3
0
votes
1 answer

Extract only few columns from a .dat file

I've to make a program with c++ for my thesis that open and extract only two columns from a file .dat that is like this, with a lot of lines: 0.000000 -9.833374 1.000000 0.156921 0.125478 0.350911 5.015625 -9.831743 1.000000 …
0
votes
0 answers

Last item of istringstream repeats?

I'm having trouble with splitting a string with sstream. It appears when the loop of cout happens, the last item of data, an integer in my case, is repeated? Is my loop set up wrong?? This is my code: #include #include #include…
Elliot
  • 97
  • 1
  • 8
0
votes
1 answer

peek() behavior in istringstrem class

I saw a lot of questions on the peek method, but mine concerns a topic which would be almost obvious, but nevertheless (I think) interesting. Suppose you have a binary file to read, and that you choose to bring up it as a whole in the program memory…
GSi
  • 649
  • 3
  • 10
0
votes
1 answer

Trouble with Out of range in memory using stringsteam

I just started using the stringstream for the first time and I love the concept, but I am having a hard time finding where exactly I am having an out of range in memory with my stringstream function. What my function does is it takes in a string,…
0
votes
1 answer

Re-setting an istringstream object

When I run this code: for (int i = 0; i < indexArray.size(); i++) { iss.str(indexArray.at(i)); iss>>one; iss>>two; iss>>three; cout<
Ester Lin
  • 607
  • 1
  • 6
  • 20
0
votes
1 answer

unwanted skipping of whitespaces

I am using this to read input: istringstream iss; string typ, data; char c1, c2; iss >> skipws >> c1 >> typ >> noskipws >> c2 >> data; input line can look like this " #text Markup used in this document is compatible with " without quotes what I…
lllook
  • 729
  • 2
  • 7
  • 20
0
votes
0 answers

Parse String into Several Parts Using a stringstream

I have an input file that has multiple lines in the current format: [message1]/[message2]/[message3] I have to extract [message#] and put each into a separate container (vector, array, etc). Is there an easy way to do this with a stringstream?…
0
votes
1 answer

beginner: on reading in from file and using istringstream

I have never used istringstream before. I have only split lines before with 1 delimiter so I don't know how to use istringstream. I am splitting lines from a file that look like this: Table, Wanted, 100 Car, For Sale, 5000 I need to split the…
klw_123
  • 9
  • 1
  • 5
0
votes
2 answers

reading space separated data and pushing it into proper contaner

I am facing a problem how to read space separated data from input stream. Lets say we need to input J 123 7 3 M. First is letter and last is letter. The rest is int. vector ints; vector chars; stringstream ss; ... cin >>…
Tukkan
  • 1,574
  • 2
  • 18
  • 33