istringstream Questions

3

Solved

I'm trying to use istringstream to split a simple string into a series of integers: #include <string> #include <iostream> #include <sstream> #include <vector> using namesp...
Forensics asked 2/3, 2011 at 14:16

6

Solved

So istringstream copies the contents of a string when initialised, e.g string moo("one two three four"); istringstream iss(moo.c_str()); I was wondering if there's a way to make std::istringstre...
Gibert asked 26/6, 2010 at 5:59

2

Solved

The std::stringstream initialization constructor accepts const string& as a parameter: explicit stringstream (const string& str, ios_base::openmode which = ios_base::in | ios_base::out); ...
Garretson asked 3/9, 2022 at 4:19

2

Solved

I am coding in Eclipse and have something like the following: #include <ftream> #include <iostream> void read_file(){ char buffer[1025]; std::istringstream iss(buffer); } However,...
Broca asked 17/11, 2012 at 6:3

1

Solved

I have a function do_something that reads unsigned characters from a stream. The stream can be created from a file given the file name. Or it can be created from the given string by considering it ...
Pindaric asked 17/7, 2020 at 18:28

1

Solved

I'm trying to set the internal buffer of an input stream, but my implementation in C++17 doesn't implement pubsetbuf() for istringstream. I've tried some other techniques, but they are slow or cop...
Kick asked 23/5, 2019 at 21:49

8

Solved

When would I use std::istringstream, std::ostringstream and std::stringstream and why shouldn't I just use std::stringstream in every scenario (are there any runtime performance issues?). Lastly, ...
Vassili asked 20/7, 2010 at 16:20

3

Data saved in my file is (white spaces added at both beginning and end on purpose for this test): 1 2 3 Loading the data using the code below with or without "std::ws" does not cause any differ...
Proto asked 3/9, 2015 at 0:37

1

I came across a difference in behavior, between gcc (4.9.2) and clang (3.5.0), which surprised me. When I try to feed an unsigned int from an std::istringstream initialized with a negative value (...
Tannenbaum asked 2/4, 2016 at 19:31

6

Solved

I want to have a variable of type istream which can hold either the contents of a file or a string. The idea is that if no file was specified, the variable of type istream would be assigned with a ...
Abundance asked 5/8, 2016 at 21:42

2

Solved

The following code splits the provided string/line down to the characters. Why does the loop repeats that last string twice? How to fix it? #include <iostream> #include <vector> #inclu...
Suu asked 15/2, 2016 at 18:8

4

Solved

In the following function, I try to see if a string s is convertible to type T by seeing if I can read a type T, and if the input is completely consumed afterwards. I want template <class T&gt...
Nissa asked 7/11, 2012 at 16:56

1

I'm trying to extract different types of data from a string. void readHeader(char buf[BUFFSIZE]) { std::istringstream hdr(buf); __uint128_t id_client; hdr >> id_client; // doesn't compil...
Inerrant asked 2/11, 2014 at 14:57

4

Solved

Why does my program not output: 10 1.546 ,Apple 1 instead of 10 1 <empty space> here's my program: #include <iostream> #include <string> #include <sstream> using na...
Ski asked 16/2, 2014 at 16:52

2

Solved

currently I am using a boost char array boost::array<char, 512> received_data; std::istringstream ss_(received_data.data()); but what if my received_data was a std::vector<char> rec...
Lotze asked 25/5, 2013 at 14:39

2

So, I've been trying to figure out, how to wait for data from a C++ stringstream (for instance), without being constantly checking if data is there, which is quite CPU consuming. I'm perfectly abl...
Boogie asked 10/9, 2012 at 11:54

2

Solved

I have a code for reading files with float numbers on line stored like this: "3.34|2.3409|1.0001|...|1.1|". I would like to read them using istringstream, but it doesn't work as I would expect: s...
Ripping asked 4/5, 2010 at 17:0

3

Solved

Can I persuade operator>> in C++ to read both a hex value AND and a decimal value? The following program demonstrates how reading hex goes wrong. I'd like the same istringstream to be able to...
Penurious asked 16/9, 2008 at 21:22
1

© 2022 - 2024 — McMap. All rights reserved.