template<class T>
std::string cast_num( T nmbr )
{
std::ostringstream s;
if( s << nmbr )
return s.str();
return "\0";
}
Does anyone know why this does not work?
It works fine with my compiler, which compiler are you using, if you are using vc++ 6.0 then it could be your compiler and time to update :D
Have you made sure your including the correct files, you need
#include <string>
#include <sstream>
That might cause that prob
#include <string>
#include <sstream>
That might cause that prob
Quote:Original post by kappa
*** Source Snippet Removed ***
I want to convert any number to a string, I found this and it looked like it would work. But when I run it I get the following error:
hl error LNK2019: unresolved external symbol _use_Q_snprintf_instead_of_sprintf referenced in function "protected: virtual class std::ostreambuf_iterator > __thiscall std::num_put >::do_put(class std::ostreambuf_iterator >,class std::ios_base &,char,long)const " (?do_put@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MBE?AV?$ostreambuf_iterator@DU?$char_traits@D@std@@@2@V32@AAVios_base@2@DJ@Z)
Anyone know anyother way I can do this? and why this does not work?
Another way: You shouldn't bother. This is legit code.
Doesn't work: Becuz your C++ standard library is broken. Which compiler are you using ?
read the thread :P
I use .net 2002, does anyone know how to use the 2002 IDE for the 2003 toolkit? I can't find any of the websites telling me how right now.
I use .net 2002, does anyone know how to use the 2002 IDE for the 2003 toolkit? I can't find any of the websites telling me how right now.
Did you examine this line:
You probably have your runtime library components mixed up between two different versions, products or vendors.
- Are you, by any chance, using STLport in VS.NET 2002 or some other STL replacement library ?
- Do you have other C++ compilers (including older/newer versions of VisualStudio) installed on this system ? (your include paths might incorporate the other compiler's directories)
-Markus-
Quote:unresolved external symbol _use_Q_snprintf_instead_of_sprintfObviously, your stringstream implementation internally uses sprintf() to perform the conversion, which is something your runtime library doesn't want you to.
You probably have your runtime library components mixed up between two different versions, products or vendors.
- Are you, by any chance, using STLport in VS.NET 2002 or some other STL replacement library ?
- Do you have other C++ compilers (including older/newer versions of VisualStudio) installed on this system ? (your include paths might incorporate the other compiler's directories)
-Markus-
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement