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
0 answers

How to use istringstream twice

Possible Duplicate: C++ - repeatedly using istringstream Given this code : string line; // for the line ifstream myfile ("input.txt"); int algorithmNumber , matrixDim; getline (myfile,line); istringstream buffer(line); buffer…
JAN
  • 21,236
  • 66
  • 181
  • 318
0
votes
1 answer

strtok or std::istringstream

I have the following code which uses strtok which receives input from a txt file. The input in the txt file is: age, (4, years, 5, months) age, (8, years, 7, months) age, (4, years, 5, months) My code looks like: char * point; ifstream…
user1823986
  • 87
  • 3
  • 11
0
votes
1 answer

Istringstream doesn't "walk" through the line

I'm trying to read in a feature vector file storing feature vectors in the following way: (label) (bin):(value) (bin):(value) etc. like: -1 5:0.015748 6:0.0472441 7:0.0393701 8:0.00787402 12:0.0314961 13:0.0944882 14:0.110236 15:0.0472441…
user1435395
  • 61
  • 1
  • 12
0
votes
3 answers

c++ istringstream

i am trying to write a c++ opengl application to load .OBJ files and i use this code to read the vertex: char buf[256]; while(!objFile.eof()) { objFile.getline(buf,256); coordinates.push_back(new std::string(buf)); } else if…
FPGA
  • 3,525
  • 10
  • 44
  • 73
0
votes
2 answers

How to use IStringStream to read from a file?

I need to read in an expression from a file using a string stream and convert the expression to into another form. But I am having trouble figuring out how to read lines from the file using the Istringstream. Can anyone help me with the #includes…
Mike
  • 477
  • 2
  • 7
  • 24
0
votes
3 answers

unexpected behavior when reading from istringstream

I have a question on the stream behavior, see the following example. What I was expecting is, since there are only 5 chars in the string, and stream read will get stuck as I am trying to read 10 chars. Instead, the output is "hellooooo" ... the last…
Oliver
  • 3,592
  • 8
  • 34
  • 37
0
votes
1 answer

New to , trying to access data in a directory

I've never used dirent.h before. I was using istringstream to read through text files (singular), but have needed to try to revise the program to read in multiple text files in a directory. This is where I tried implementing dirent, but it's not…
Heather Wilson
  • 153
  • 2
  • 4
  • 13
-1
votes
2 answers

Why I can't read an integer from a stringstream which has some words followed by an integer?

I am a beginner in C++, just want to know why I cannot show the 6.9 in the second line of my output? Does it seem like I ignore the word 'lady' and then just break the getline while loop and then move to the other line? #include #include…
-1
votes
1 answer

Extraction Operator reaching EOF on istringstream, behavioral change with int/char/string

So I am doing some simple file I/O in c++ and I notice this behaviour, not sure if I am forgetting something about the extraction operator and chars Note that the file format in Unix. ifstream infile("test.txt"); string line; while(getline(infile,…
DR. Palson_PH.d
  • 301
  • 1
  • 3
  • 11
-1
votes
3 answers

C++ Reading population records from a file

I am trying to write a C++ program that takes a list of population records from a file an exert is given below: Jackson 49292 Levy 40156 Indian River 138894 Liberty 8314 Holmes 19873 Madison 19115 Is there a good way to handle the Indian River…
-1
votes
1 answer

How to initialize declared istringstream with string?

In C++, how do you initialize a declared istringstream with a string? example.hpp #include class example{ private: istringstream _workingStream; public: example(); } example.cpp example::example(){ …
Eugene
  • 10,957
  • 20
  • 69
  • 97
-1
votes
1 answer

Assigning variables from configuration file to int16_t variables in c++

I have use stringstream to parse the configuration file. The c++ integer variables are working fine while assigning the values from the text file.However, when I assign the read value from configuration file to c++ int16_t variables, it just assigns…
nzy
  • 854
  • 2
  • 15
  • 28
-1
votes
2 answers

How to split string by my own delimiter

The program should take as input the digit infused string and the digit delimiter, and output the 4 words on separate lines. Example Please enter a digit infused string to explode: You7only7live7once Please enter the digit delimiter: 7 The 1st word…
Veronica
  • 15
  • 1
  • 3
-1
votes
1 answer

using stringstream and getline to read the first two numbers of each line

What I need to do: I have a vector of lines right now, v[0] is the first line and so on. I would like to read the first number from each line as the challenge and the second number from each line as the judge and then apply the conditions in the…
-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 2 3
14
15