[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



Since you're using C++, have you tried using the C++-style streaming
operators?  For example,
  #include <sstream>
  // ...
  std::istringstream iss(tmp, std::istringstream::in);
  tmp >> wVar;

The atoi() function, as well as countless other C-style standard functions,
are considered "legacy" when used in a modern C++ (i.e., has a robust
Standard Template Library (STL)) development context.  

>   sprintf((char*)wVar,"%u",tmp);
> Compiles and doesn't crash at runtime, but I'm getting a zero value which 
> isn't right.  Setting the value staticly, like sprintf((char*)wVar,"2")  
> gives me a zero value too.

This does the exact opposite of what you need.  You'd want to try sscanf()
instead, but remember that these functions, like atoi(), are considered
"legacy" in a modern C++ context.


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00144" href="msg00144.html">[ale] OT: c++ datatypes question</a></strong>
<ul><li><em>From:</em> jtaylor at onlinea.com (J.M. Taylor)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00145.html">[ale] chmod question</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00147.html">[ale] OT: c++ datatypes question</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00144.html">[ale] OT: c++ datatypes question</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00147.html">[ale] OT: c++ datatypes question</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00146"><strong>Date</strong></a></li>
<li><a href="threads.html#00146"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>