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
-1
votes
3 answers

Recursive Function Seriously slowing performance?

I have a function which I am calling an infinite amount of times (or until a condition is met). The problem with this recursive function is that on a higher level, it is called by a worker thread which pushes and pops to a deque. In the meantime, I…
-1
votes
1 answer

C++ Code compiles but I get a segmentation fault when running it. I think I'm mangling linked lists

Hello everyone, first post here. So its going into the weekend and I don't have access to my course instructor. This is our first project using linked lists and I'm mangling it pretty good. The fault is, I'm pretty sure, on line 53 of sl_list.cpp…
Lando242
  • 3
  • 1
-1
votes
1 answer

Int returns long number when used in a stringstream?

I've been building a program that converts one model file type to a wavefront obj one, but I've ran into a problem when writing my faces to that file. if(!strcmp(line , "TEX:TOP")) { i++; TEX_TOP << "f " << i << "/" << i…
siba
  • 43
  • 1
  • 7
-1
votes
5 answers

how do I assign an int to a string with stringstream?

How do I assign an int to a string with stringstream? The "stringstream(mystr2) << b;" doesn't assign b to mystr2 in the example below: #include #include #include using namespace std; int main() { string mystr =…
Ricardo Zorio
  • 282
  • 5
  • 11
-1
votes
1 answer

OpenGL: setting up indices/vertices

I have been trying to write a very simple .obj model loader in c++ but in both of my methods the model doesn't get displayed correctly and I would also like to know which of the 2 methods is faster/better and why. this is my first method: …
Anton D
  • 1,336
  • 1
  • 12
  • 18
-1
votes
2 answers

std::stringstream does not name a type (Global)

I'm doing a simulation of a few Ising models (lattice with 1 or -1) and I don't want to use files (don't gonna get into details here, I guess :D). So, the thing is, I'm using stringstreams to format the data & data's filename to then separate them…
stringparser
  • 735
  • 1
  • 6
  • 16
-1
votes
2 answers

appending a float to a stringstream in cpp

I am trying to write a sentence inside a stringstream. Here is my sketch: stringstream is; float position_angle0; position_angle0=12.5; is << "setpos1 0 %d ", int(position_angle0); I guess there is something wrong because it seems not working.…
-2
votes
2 answers

Convert a string array with special characters to an int array. Inputs are from a file

My problems here is to take all the integers in a file, and store to an int array (of course without |), and then do something with it (here I just need help to print out the array). The data from the file is said to be a 10x10 matrix. My code…
-2
votes
1 answer

why is my stringstream giving me empty when i have already printed out the contents of my object to console

I have overloaded the << operator here. I tried printing out the object in my main class and it looks perfect. The problem is when I try to pass that object to stringstream, the string stream object gives me empty. stringstream printing code
-2
votes
1 answer

Ignoring whitespace in string stream doesn't work with skipws flag

I am trying to solve a problem that evaluates simple expressions in a string like 10+20 should return 30 The problem is the string can contain white spaces so i uses stringstring with skipws flag it works for white spaces within the string like 10 +…
user3279954
  • 556
  • 2
  • 7
  • 22
-2
votes
1 answer

Convert an input stream to a double vector

I am having issues getting an input line of comma-delimited numbers to properly pass into a double vector. I'm mildly new to C++ and am in a bit of a pickle. I've tried using a double array, but double vectors seem to work better. int main(){ …
CurlyCue
  • 35
  • 1
  • 2
-2
votes
1 answer

I cant get stringstream to compile

I'm writing a simulation program in C++. I have several years programming experience but haven't done any at all in 15 years. It is my first time programming in C++. The simulation contains several hundred lines of code and works ok. My primary goal…
-2
votes
1 answer

Delimiter at the start of a string

I am splitting a string into smaller pieces based off of the delimiter "/". stringstream ss(stringToSplit); string item; vector splitStrings; while (std::getline(ss, item, delimiter)) { splitStrings.push_back(item); } some of the…
Kirby
  • 77
  • 9
-2
votes
3 answers

Reading two hex values from text file in c++

I have a file which is formatted in the following way: 0x10c3 0xad6066 0x10c7 0xad6066 0x10c1 0xad6066 0x10c5 0xad6066 0x10c3 0xad6066 I want to read the first value into an array input[] and the second into array param[]. I tried the…
Invariance
  • 313
  • 6
  • 16
-2
votes
2 answers

C++ << no operator found

string toString() { std::stringstream punkte; std::stringstream name; std::cout << name << "hat" << punkte << "Punkte" << '\n' return 0; } At this line of code. I'm receiving the error C++ << no operator found I can't figure…