Boost logo

Boost Users :

Subject: Re: [Boost-users] lexical problem
From: Anders Dalvander (boost_at_[hidden])
Date: 2009-09-15 13:40:28


pedro chaparro wrote:
> in the ouput i have this : 5050??
>
> the first "50" i write with
> std::cout.write(buf.data(),len);
>
> and the second "50" plus those stange characters
>
> std::string datos=buf.data();
> printf("%s \n",datos);
>
> i suppose that those characters means that are not null terminated. right?
> So how can i only take the "50" without the other characters?
>
> thanks
>

std::string does not work well with varargs, use std::string::c_str
member function to convert it to a null-terminated string:

printf("%s \n",datos.c_str());

Regards,
Anders Dalvander


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net