[LC++]<sstream>

Lawrence Sim lsim_au at yahoo.com.au
Thu Dec 13 10:00:06 UTC 2001


On Thu, 13 Dec 2001 03:29, Roberto Diaz wrote:
> Hi!
>
> I am trying to implement a single stream to a string.
> Following Stroustrup it says ostringstream is declared in <sstream>,
> in my system (debian potato) I find the following error:
>
> #include <sstream>
> #include <string>
>
> std::string intToString (int a)
> {
>   std::ostringstream o;
>   if (o << a)
>     return o.str (); //
>   return "error"; // we still havent an error handler
> }
>
> g++ -c -ggdb -o bwwidget.o bwwidget.cc
> bwwidget.cc:9: sstream: No such file or directory
>
> and really I find I can not find any file in my sistem called
> sstream.. (I have all the rest).

It should be in something like /usr/include/g++-3/sstream, if it is not 
there, get an updated copy of g++ off the web.

> Whats happening? :??

The conversion in the if is always going to work, as you are giving it 
an int, so the value contained in that int must be within the valid 
range of an int.

-- 
Lawrence Sim
Web: http://users.bigpond.net.au/Lawrence_Sim/
'Such is Life' - Ned Kelly, just before he was hanged.

John			Dame May		Oscar
Was Gay			Was Whitty		Was Wilde
But Gerard Hopkins	But John Greenleaf	But Thornton
Was Manley		Was Whittier		Was Wilder
		-- Willard Espy



More information about the tuxCPProgramming mailing list