[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Mon Jun 7 15:16:00 2004 -->
- <!--x-from-r13: nyr ng ThygbaUerra.pbz (Thygba Uerra) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: Pine.LNX.4.44.0406071421010.7716-[email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] OT: c++ datatypes question -->
- <li><em>date</em>: Mon Jun 7 15:16:00 2004</li>
- <li><em>from</em>: ale at FultonGreen.com (Fulton Green)</li>
- <li><em>in-reply-to</em>: <<a href="msg00144.html">[email protected]</a>>; from [email protected] on Mon, Jun 07, 2004 at 03:01:07PM -0400</li>
- <li><em>references</em>: <<a href="msg00144.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] OT: c++ datatypes question</li>
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>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00148" href="msg00148.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-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="msg00146.html">[ale] OT: c++ datatypes question</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00148.html">[ale] OT: c++ datatypes question</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00146.html">[ale] OT: c++ datatypes question</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00148.html">[ale] OT: c++ datatypes question</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00147"><strong>Date</strong></a></li>
<li><a href="threads.html#00147"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>