Questions tagged [sstream]
111 questions
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
2 answers
Using preprocessor directives with cout and stringstream in interactive program - C++
so if I have a simple interactive program like this:
#include
#include
#include
#include
#define cout os
int main() {
stringstream os;
cout << "If you would like to continue, type 'Continue'" <<…

user313
- 681
- 1
- 8
- 21
0
votes
2 answers
Why am I getting a timeout(using sstream to parse list of integers separated by commas)?
I am given an input string of n integers, separated by commas (e.g. "23,4,56"). I need to set a stringstream to represent this string and then use it to scan each integer into a vector. The elements of the vector (the integers in the list) will end…

Yang-Yang Feng
- 31
- 4
0
votes
1 answer
what library to use for stoi keyword in c++
my question is pretty simple but I can't seem to find it out.
I want to know what libary to include when using stoi. I was using atoi and it works fine with
#include
#include
#include
using namespace std;
but I get…

Safwan Ull Karim
- 652
- 5
- 10
- 20
0
votes
1 answer
Split a larger string and stop if a particular character is found
The input is a standard string input. Like this.
"Anand,Ramesh,Suresh#Anand,Ramesh,Suresh,Suresh,Anand"
I want to get get all the Names before the # and store it in an array. And use the names after the # to do some operation.
How do I copy the…

Shivji
- 39
- 1
- 7
0
votes
1 answer
sstream not populating vector C++
With input in the command line:
1 2 3
Which is stored in 'line' my vector is only being populated with
1
What am I doing wrong?
Here is the code
string line;
string buffer;
int a,b,base;
cin >> line;
stringstream ss(line);
…

Barney Chambers
- 2,720
- 6
- 42
- 78
0
votes
2 answers
What is the best way (performance driven) to convert and write variables to a file in c++?
I want to write something like this to a file:
0x050 addik r13, r0, 4496
0x054 addik r2, r0, 2224
0x058 addik r1, r0, 7536
0x05c brlid r15, 200
...
And so on... Its a program instruction trace which will have thousands of lines.
I am reading from…

joaomlap
- 195
- 3
- 13
0
votes
1 answer
What is a possible way to store data from a stringstream into an unsigned long?
I am trying to make a program which puts the contents stored in a stringstream (a large number) into an unsigned long format. But the compiler shows an error
error: invalid user-defined conversion from 'std::stringstream {aka…

Vaibhav
- 13
- 2
0
votes
1 answer
Is there method of in place string manipulation native to the mingw libraries that doesn't involve i/o streams
I am attempting to construct a serial number of a certain format. This number will be entered into a database. At this point I am having to use sprintf, but I would like a native C++ method for it.
Here is sample code:
int i;
sprintf(buffer,…

pwn01
- 31
- 1
- 8
0
votes
1 answer
Does stringstream (or boost) have some smart format feature?
I am writing some hobby code today for fun, and while I did some stuff I came along something interesting that I would like to do in a way that sounds and looks nice/great/cool.
The idea is basically that you have a string in C++ and you pass it to…

Gizmo
- 1,990
- 1
- 24
- 50
0
votes
2 answers
Not getting all lines from a text file when using getline() in C++
I was given a homework assignment to generate a txt file containing a random number of lines, each with a random amount of integers, ranging between a minimum value and a maximum value. Lots of rand() fun.
In any case, that was the easy part. The…

Gil Dekel
- 355
- 4
- 15
0
votes
1 answer
Reading multiple data from string, separated by characters using sstream
I have .txt file with text like this inside (this is just a fragment):
...
[332, 605]-[332, 592], srednica: 13
[324, 593]-[332, 605], srednica: 14.4222
[323, 594]-[332, 605], srednica: 14.2127
[323, 594]-[331, 606], srednica: 14.4222
[324,…

countryroadscat
- 1,660
- 4
- 26
- 49
0
votes
1 answer
Issues in using istringstream
#include
#include
#include
#include
using namespace std ;
int main()
{
ifstream infile ;
infile.open("input.txt") ;
string line ;
int noOfVar,noOfCubes ;
getline(infile,line) ;
…

abkds
- 1,764
- 7
- 27
- 43
0
votes
1 answer
Cant get this to update the variables C++
I'm writing a program that is a calculator where you would type in the sum and it would give you the answer. That part works fine. The problem I am having is taking the answer of the previous sum and doing a calculation with that.
Like: 5 + 5 = 10…

Gordy
- 15
- 5
0
votes
2 answers
C++ Reading a Large File and Putting Data in an Array
I have a file with 500,000 random (6-7 digit) numbers. I want to write all the numbers, one at a time, to an array. A Vector will work flawlessly in this code BUT, I'm afraid my teacher just won't allow the use of Vectors. Here is my code:
int…

cerealspiller
- 1,401
- 3
- 14
- 23