Questions tagged [stringstream]

stringstream provides an interface to manipulate strings as if they were input/output streams.

The objects of this class maintain internally a pointer to a stringbuf object that can be obtained/modified by calling member rdbuf. This streambuf-derived object controls a sequence of characters (string) that can be obtained/modified by calling member str.

1178 questions
-2
votes
1 answer

C++ using getline and stringstream with multiple classes and overloaded stream operator

I'm working on a university assignment to read in data from a file and could really use some help! The data file contains weather data and looks like: 31/03/2016 9:00,14.6,175,17,0,1013.4,1016.9,1017,0,68.2,6,512,22.7,24.1,25.5 The assignment…
-2
votes
1 answer

C++ ignores blanks in a text file using a Stringstream for reading

I try to read several lines from a textfile and want to store the single items in a struct. The code looks like this: std::string line; struct _DomainTable_ line_of_file; while (getline(infile_, line)) { std:: stringstream linebuffer(line); …
Hoeh
  • 45
  • 4
-2
votes
1 answer

Segmentation fault (core dumped) using stringstream in multithread application

I trying do simple threadsafe logger, which print messages to console. // Test function for check logger. It is work void test(double& diff) { std::vector result; for( int counter = 0; counter < 100000; ++counter) { …
-2
votes
1 answer

How do you return the next token from a stringstream without operator>>?

How do you get a std::stringstream to return the next token, instead of extracting it into a variable with operator>>? I've included some examples of why I would want to do this below. I've tried get(), but this just returns the next…
John Terry
  • 19
  • 5
-2
votes
2 answers

istream_iterator behaviour on 0x9-0xD

I have written a small test file to make the question clear : #include #include #include #include #include void printChar(const char c) { std::string s(&c); std::istringstream…
fzd
  • 765
  • 1
  • 6
  • 19
-2
votes
1 answer

Reading an input file line by line using string stream

I have a data file "records.txt" that has the following form: 2 100 119 107 89 125 112 121 99 124 126 123 103 128 77 85 86 115 66 117 106 75 74 76 96 93 73 109 127 110 67 65 80 1 8 5 23 19 2 36 13 16 24 59 15 22 48 49 57 46 47 27 51 6 30 7 31 41 17…
Leigh K
  • 561
  • 6
  • 20
-2
votes
2 answers

Segmentation fault while returning from function in c++

I using stringstream for parsing string, however it is unexpectedly giving segmentation fault while exiting from function. bool check_if_condition(int a) { string polygonString1="19.922379 51.666267 19.922381 51.665595 19.921547 51.665705…
Alexander Fell
  • 185
  • 1
  • 11
-2
votes
1 answer

split string into character and integer c++

I am working on a small assignment, and part of it requires me to split the string into integers and characters. These integers and characters are then stored in separate vectors. For example, if I enter '* + / 9 8 7', I want to store the '*','+'…
VVSTITAN
  • 113
  • 1
  • 2
  • 9
-2
votes
1 answer

Access violation when using std::stringstream on windows

I am currently implementing a rudimentary file load function. When using a std::stringstream the program crashes with a access violation in the stringstream destructor. Here is the function: void macro_storage_t::load(std::string filename) { …
Nidhoegger
  • 4,973
  • 4
  • 36
  • 81
-2
votes
1 answer

C++ Retrieve const char* from stringstream

I have no idea about what's wrong here. std::stringstream ss("Title"); ss << " (" << 100 << ")"; const char* window_title = &ss.str().c_str(); I've ran make and it was not happy. [17%] Building CXX object CMakeFiles/game.dir/src/main.cpp.o path:…
Lucien
  • 776
  • 3
  • 12
  • 40
-2
votes
1 answer

Line reversal from input file only doing one line?

I am trying to figure out why I am only getting one line while using getline from the file. I am using reverse to flip all of the letters then turning the string into a stringstream. I am then pulling each word out of the stream and reversing them…
ryanpback
  • 275
  • 4
  • 17
-2
votes
2 answers

Would a stingstream work to convert an int to a sting?

I recently read a question about turning strings to integers - (Easiest way to convert int to string in C++). I know what itoa is, but what are stringstreams and how are they used? I am trying to implement a way to tell if an integer is a…
Noah Gonzales
  • 31
  • 4
  • 9
-2
votes
1 answer

Stringstream won't convert properly

To begin with, I'm using Windows 8.1, Visual Studio 2013 Express and c++. Don't know which C++ standard I'm using though. I'm completely new to programming so I might have missed some fundamental part in this function. I am making a 10-question quiz…
-2
votes
1 answer

Convert void* to stringstream

What is the best way to convert a void* to stringstream? I need to convert incoming curl data to be able to parse it. I have done the following and it appears to work but Im sure there is a better way void ProcessData(void* data, size_t…
Harry Boy
  • 4,159
  • 17
  • 71
  • 122
-2
votes
1 answer

Why Can't I Use istream_iterators in a vector Ctor?

I want to do this: std::istringstream foo( "13 14 15 16 17 18 19 20" ); std::vector bar( std::istream_iterator( bytes ), std::istream_iterator() ); But rather than recognizing it as the vector range ctor, the compiler thinks that I'm…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288