<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: sscanf with CString</title>
	<atom:link href="http://www.ucosoft.com/sscanf-with-cstring.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ucosoft.com/sscanf-with-cstring.html</link>
	<description>Free Source Code and Program Tips</description>
	<lastBuildDate>Wed, 21 Dec 2011 16:05:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Michael Yanni</title>
		<link>http://www.ucosoft.com/sscanf-with-cstring.html/comment-page-1#comment-4844</link>
		<dc:creator>Michael Yanni</dc:creator>
		<pubDate>Tue, 29 Mar 2011 17:45:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.ucosoft.com/archives/76.html#comment-4844</guid>
		<description>This poster does not know what he is talking about. There is a version of sscanf made for Unicode charaters. There is also a secure version of sscanf. If you use that function appropriately, you can use CStrings correctly. Here is the example described above done using _stscanf_s and CStrings:

const unsigned int kuBufferSize = 20;
CString strField = _T(&quot;Microsoft Bill&quot;);
CString strName(_T(&quot;&quot;), kuBufferSize);
CString strPassword(_T(&quot;&quot;), kuBufferSize);
int nItemCount = 0;

nItemCount = _stscanf_s(strField, _T(&quot;%s %s&quot;), strName, kuBufferSize, strPassword, kuBufferSize);

OutputDebugString(strName);
OutputDebugString(_T(&quot;\n&quot;));

OutputDebugString(strPassword);
OutputDebugString(_T(&quot;\n&quot;));

This code produces this in the Debug output window in Visual Studio:

Microsoft
Bill

These values are appropriately stored in the variables:
strName = _T(&quot;Microsoft&quot;);
strPassword = _T(&quot;Bill&quot;);
nItemCount = 2;

I didn&#039;t need this solution for my situation, but I was intrigued on how to solve yours. I simply needed to get an integer out of a CString, so I used the solution above except for integers. For more information, see the documentation here:
http://msdn.microsoft.com/en-us/library/t6z7bya3%28v=VS.90%29.aspx</description>
		<content:encoded><![CDATA[<p>This poster does not know what he is talking about. There is a version of sscanf made for Unicode charaters. There is also a secure version of sscanf. If you use that function appropriately, you can use CStrings correctly. Here is the example described above done using _stscanf_s and CStrings:</p>
<p>const unsigned int kuBufferSize = 20;<br />
CString strField = _T(&#8220;Microsoft Bill&#8221;);<br />
CString strName(_T(&#8220;&#8221;), kuBufferSize);<br />
CString strPassword(_T(&#8220;&#8221;), kuBufferSize);<br />
int nItemCount = 0;</p>
<p>nItemCount = _stscanf_s(strField, _T(&#8220;%s %s&#8221;), strName, kuBufferSize, strPassword, kuBufferSize);</p>
<p>OutputDebugString(strName);<br />
OutputDebugString(_T(&#8220;\n&#8221;));</p>
<p>OutputDebugString(strPassword);<br />
OutputDebugString(_T(&#8220;\n&#8221;));</p>
<p>This code produces this in the Debug output window in Visual Studio:</p>
<p>Microsoft<br />
Bill</p>
<p>These values are appropriately stored in the variables:<br />
strName = _T(&#8220;Microsoft&#8221;);<br />
strPassword = _T(&#8220;Bill&#8221;);<br />
nItemCount = 2;</p>
<p>I didn&#8217;t need this solution for my situation, but I was intrigued on how to solve yours. I simply needed to get an integer out of a CString, so I used the solution above except for integers. For more information, see the documentation here:<br />
<a href="http://msdn.microsoft.com/en-us/library/t6z7bya3%28v=VS.90%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/t6z7bya3%28v=VS.90%29.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antonio</title>
		<link>http://www.ucosoft.com/sscanf-with-cstring.html/comment-page-1#comment-4770</link>
		<dc:creator>Antonio</dc:creator>
		<pubDate>Fri, 27 Mar 2009 14:04:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.ucosoft.com/archives/76.html#comment-4770</guid>
		<description>Well, you are casting an object on the stack as if it is a pointer, what do you expect, no crash ?</description>
		<content:encoded><![CDATA[<p>Well, you are casting an object on the stack as if it is a pointer, what do you expect, no crash ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: support</title>
		<link>http://www.ucosoft.com/sscanf-with-cstring.html/comment-page-1#comment-4766</link>
		<dc:creator>support</dc:creator>
		<pubDate>Wed, 04 Feb 2009 03:07:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.ucosoft.com/archives/76.html#comment-4766</guid>
		<description>&lt;a href=&quot;#comment-4757&quot; rel=&quot;nofollow&quot;&gt;@Adam Gross&lt;/a&gt; You are completely right.</description>
		<content:encoded><![CDATA[<p><a href="#comment-4757" rel="nofollow">@Adam Gross</a> You are completely right.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Gross</title>
		<link>http://www.ucosoft.com/sscanf-with-cstring.html/comment-page-1#comment-4757</link>
		<dc:creator>Adam Gross</dc:creator>
		<pubDate>Fri, 02 Jan 2009 04:30:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.ucosoft.com/archives/76.html#comment-4757</guid>
		<description>As far as I can tell, using _tscanf_s with CString is still bad because CString with UNICODE defined is UTF16 but all of these functions expect UTF8.  We either need to convert it or to find some Windows-provided ones that expect UTF16.</description>
		<content:encoded><![CDATA[<p>As far as I can tell, using _tscanf_s with CString is still bad because CString with UNICODE defined is UTF16 but all of these functions expect UTF8.  We either need to convert it or to find some Windows-provided ones that expect UTF16.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

