Questions tagged [ostringstream]

Output stream class to operate on strings.

150 questions
1
vote
1 answer

c++ ostringstream object causing unhandled exception after returning main function

Unhandled exception at 0x53e83d80 in TestGame.exe: 0xC0000005: Access violation reading location 0xfeeefef6. My C++ program throws an unhandled exception when I close my SFML window (causing the main class to return 0; The code causing…
1
vote
1 answer

When trying to concatenate a string in ostringstream, which string contents are modified and reconstructed, string get added at beginning

Possible Duplicate: What is the purpose of ostringstream's string constructor? I am facing below issue. I have an ostringstream say testStr. I first insert few characters inside it using << testStr << somechar; Then I modified: testStr.Str("some…
learningstack
  • 358
  • 1
  • 4
  • 15
1
vote
2 answers

OStringStream and Namespaces Issue C++

so I wanted to convert an integer into a string but using itoa isn't standard so through my research I figured the best way to do it would be to use OStringStream. Here's some pseudo-code: #include #include #include…
prince
  • 506
  • 6
  • 18
1
vote
1 answer

Extracting bytes from byte stream

I receive a binary file via POST in a C++ CGI script and I'm using the Cgicc library to get its contents like so: std::ofstream myfile; myfile.open ("file.out", std::ios::in | std::ios::binary); try { cgicc::Cgicc cgi; …
Mihai Todor
  • 8,014
  • 9
  • 49
  • 86
1
vote
3 answers

ostringstream operator[] giving compile error when trying to read buffer

I have a class that extends ostringstream class. Class A: public ostringstream { } I want to read data of specified size and a specific offset from that object. So trying: A a_; a_ << data1 << data2; string datax(a_[offset], size); But getting…
Romonov
  • 8,145
  • 14
  • 43
  • 55
1
vote
2 answers

ostringstream conversion from VS6 to VS2010

I have this code that work's well under VS6 but gives me errors in VS2010 : void CGreatString::operator>> (char * lpszDest) { strcpy (lpszDest, str()); rdbuf()->freeze(0); } I have found this for something similar to my problem, but it still didn't…
LolCat
  • 539
  • 1
  • 11
  • 24
0
votes
1 answer

Returning a string stream (char*)

My professor wants me to output the "area" from calculateArea as a char/string. I'm not sure exactly what he means, but maybe some of you might understand. #include #include "math.h" #include #include #include…
Jon Wei
  • 1,481
  • 2
  • 10
  • 18
0
votes
3 answers

How to manage 'ostringstream' object in C++?

This is a snippet of code from C++ program. string TwoSeries::getArrays() { ostringstream outIndex; ostringstream outValueA; ostringstream outValueB; string stA; string stB; string valueA; string index; int *arA; …
ucas
  • 417
  • 1
  • 11
  • 30
0
votes
1 answer

Trouble with classes using stringstream

I am doing a practice problem in HackerRank, and I am having trouble implementing the final task for this one issue I am having with classes. It is a pretty simple program, it just uses a Student class with setter and getter functions to take in a…
Parke
  • 13
  • 1
0
votes
2 answers

Should I use string or ostringstream or stringstream for fileIO in C++

I want to write to the beginning of a large file using C++ using fstreams. The method I came up with is to write the entire data to a temporary file, then writing to the original file and then copying the data from the tmp file to the original…
Someone
  • 126
  • 8
0
votes
0 answers

Can strings and integers/floats be mixed when formatting via ostringstream

I'm trying to fully understand how to use ostringstream to modernize some code that uses sprintf. The problem is in replacing test code that generates random or sequential data. Here's a simplified example: char num[6], name[26]; sprintf(num,…
Joe Abbate
  • 1,692
  • 1
  • 13
  • 19
0
votes
1 answer

Can't get my FPS number to show with SFML

I am making a program that needs to have my FPS counter listed on the top left of the screen. I am using SFML to output my program into a window. I have an FPS.cpp file that contains the class for my FPS counter. There are two methods in this…
0
votes
0 answers

Passing a refereference to ostrigstream to a function

I'm trying to pass istringstream and ostringstream by reference to a void function which would extract some substrings from the string passed in istringstream and put them into the ostringstream. The istringstream seems to be working OK, but I am…
RonD
  • 9
  • 1
0
votes
3 answers

This comparison between a vector of numbers converted to a string and a string from a text file is not working?

I am trying to compare a vector of doubles to a string of numbers. In the code below I just copied a line from the txt file and put it in the vector, converted each number to a string and concantenated it. Then the program reads lines from the same…
Yugenswitch
  • 125
  • 2
  • 5
0
votes
1 answer

std::ostringstream with floats behaves different with Embarcadero's CLANG compiler

I am facing a very odd behaviour of the Embarcadero C++ Builder when using the CLANG compiler. The example is very simple: void __fastcall TForm1::Button1Click(TObject *Sender) { std::wostringstream woss; woss << std::wstring(L"N°1: ") <<…
Herwig
  • 316
  • 1
  • 17