m0nkeymafia

In C++ it is seamingly difficult to concatonate different types easily.

Fear not the STL and m0nkeymafia are here to help

Observe stringstreams in action Applause
int num1 = 24;
float num2 = 7.45;
std::stringstream formatter;
formatter << "My Age Is: " << num1 << ", my penis size is: " << num2;

//you can get the string via formatter.str(), you can even get the character array via formatter.str().c_str()

You can, like mentioned in a previous post, modify the widths of numbers, and other such things.
STL FTW

perkiset

Streams rock, but I have a hard time grokking them. When I apply myself to looking at the mechanics and syntax of using functions for them I can make it work, but for some reason I have this huge block about them... particularly when mixing file streams and web streams and string streams and soft flowing clear blue streams... just hard to get my arms around.

Perhaps it's even the sort of "backward" notation of the example you posted - just bounces off my brain.

m0nkeymafia

Yeah streams rock, anything i can helop with lemmie know perk
sorry im drunk mauhahaa  Applause

thedarkness

I always seem to use std:Applausestringstream in my code, apart from the fact that they have a different inheritance tree and ostrstream is output specific what is the difference?

Cheers,
td

m0nkeymafia

dont know diff between the two
ostringstreams rock though
there is a bug where std::stringstream implementation in vs2005 actually leaks memory slowly.
so always use ostringstream for most your string stuff.

my favourite thing is making classes and functions that output to a stream
i.e. you pass it a std:Applausestream & and then you can pass it a file stream, string stream, or whatever, and itll work, and be nice and sekzy yay

thedarkness

Under do

tnet

  I'd be using a stringbuilder object.

Cheers,
td


Perkiset's Place Home   Politics @ Perkiset's