Re: [Boost-users] lexical problem
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
2009/9/14
std::string datos=buf.data(); *>> rxint=boost::lexical_cast(datos);* //(here is the problem)
Is the data in buf nul char terminated? Is the numeric data actually numeric and not something else?
Cliff
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Ing Pedro Alonso Chaparro Valero Ciudad Politecnica de la Innovación iTEAM - Mobile Communications Group Polytechnic University of Valencia C\ Camino de Vera S/N, Edificio 8G 46022 Valencia, Spain
does not work either =(, i dont understand why can i not do this :
std::string datos(buf.data(),2);
printf("%s \n",datos);
datos must not be a string?? i get and error where say me datos is an
integer. =s
client7array.cpp:80: warning: cannot pass objects of non-POD type ‘struct
std::string’ through ‘...’; call will abort at runtime
client7array.cpp:80: warning: format ‘%s’ expects type ‘char*’, but argument
2 has type ‘int’
thanks
2009/9/15 Igor R
So how can i only take the "50" without the other characters?
std::string datos(buf.data(), 2); _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Ing Pedro Alonso Chaparro Valero Ciudad Politecnica de la Innovación iTEAM - Mobile Communications Group Polytechnic University of Valencia C\ Camino de Vera S/N, Edificio 8G 46022 Valencia, Spain
does not work either =(,
what exactly doesn't work? what error do you have? can you post an exact reproducing excerpt?
i dont understand why can i not do this : std::string datos(buf.data(),2); printf("%s \n",datos);
because printf is a C function that knows nothing about std::string. it should be: printf("%s \n", datos.c_str());
participants (3)
-
cliffg@codewrangler.net
-
Igor R
-
pedro chaparro