<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EvoTalk &#187; cpp</title>
	<atom:link href="http://evotalk.net/blog/tag/cpp/feed" rel="self" type="application/rss+xml" />
	<link>http://evotalk.net/blog</link>
	<description></description>
	<lastBuildDate>Mon, 07 Jun 2010 03:01:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sort Map Value</title>
		<link>http://evotalk.net/blog/2009/07/sort-map-value.html</link>
		<comments>http://evotalk.net/blog/2009/07/sort-map-value.html#comments</comments>
		<pubDate>Thu, 30 Jul 2009 11:05:35 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[程式設計]]></category>
		<category><![CDATA[cpp]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=1266</guid>
		<description><![CDATA[use stl set to simulate map
view plain

CODE:




#include &#38;lt;iostream&#38;gt;


#include &#38;lt;vector&#38;gt;


#include &#38;lt;algorithm&#38;gt;


#include &#38;lt;set&#38;gt;


#include &#38;lt;map&#38;gt;


using namespace std;


&#160;


class compare


&#123;


public:


 


 //the error is over here


 bool operator&#40;&#41;&#40;pair&#38;lt;int, int&#38;gt; p1, pair &#38;lt;int, int&#38;gt; p2&#41; const


 &#123;


  if &#40;p1.second == p2.second&#41;


   return p1.first &#38;lt;p2.first;


  else


     return p1.second &#38;lt;p2.second;


 &#125;


&#125;;


&#160;


typedef set&#38;lt;pair&#38;lt;int, int&#38;gt;, compare&#38;gt; MMap;


&#160;


void main&#40;int argc, char* argv&#91;&#93;&#41;


&#123;


 MMap D;


 D.insert&#40;make_pair&#38;lt;int, int&#38;gt;&#40;1, 10&#41;&#41;;


 D.insert&#40;make_pair&#38;lt;int, int&#38;gt;&#40;2, 2&#41;&#41;;


 D.insert&#40;make_pair&#38;lt;int, int&#38;gt;&#40;3, 2&#41;&#41;;


 D.insert&#40;make_pair&#38;lt;int, int&#38;gt;&#40;4, 3&#41;&#41;;


 D.insert&#40;make_pair&#38;lt;int, int&#38;gt;&#40;5, 6&#41;&#41;;


&#160;


 MMap::const_iterator iter&#40;D.begin&#40;&#41;&#41;;


 MMap::const_iterator [...]]]></description>
			<content:encoded><![CDATA[<p>use stl set to simulate map</p>
<div class="igBar"><span id="lcode-2"><a href="#" onclick="javascript:showCodeTxt('code-2'); return false;">view plain</a></span></div>
<div class="shadow">
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-2">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#include &amp;lt;iostream&amp;gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#include &amp;lt;vector&amp;gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#include &amp;lt;algorithm&amp;gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#include &amp;lt;set&amp;gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#include &amp;lt;map&amp;gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">using namespace std;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">class compare</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">public:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color:#FF9933; font-style:italic;">//the error is over here</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> bool operator<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#40;</span>pair&amp;lt;int, int&amp;gt; p1, pair &amp;lt;int, int&amp;gt; p2<span style="color:#006600; font-weight:bold;">&#41;</span> const</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  if <span style="color:#006600; font-weight:bold;">&#40;</span>p1.<span style="">second</span> == p2.<span style="">second</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   return p1.<span style="">first</span> &amp;lt;p2.<span style="">first</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  else</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">     return p1.<span style="">second</span> &amp;lt;p2.<span style="">second</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">typedef set&amp;lt;pair&amp;lt;int, int&amp;gt;, compare&amp;gt; MMap;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">void main<span style="color:#006600; font-weight:bold;">&#40;</span>int argc, char* argv<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> MMap D;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> D.<span style="">insert</span><span style="color:#006600; font-weight:bold;">&#40;</span>make_pair&amp;lt;int, int&amp;gt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">1</span>, <span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> D.<span style="">insert</span><span style="color:#006600; font-weight:bold;">&#40;</span>make_pair&amp;lt;int, int&amp;gt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">2</span>, <span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> D.<span style="">insert</span><span style="color:#006600; font-weight:bold;">&#40;</span>make_pair&amp;lt;int, int&amp;gt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">3</span>, <span style="color:#800000;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> D.<span style="">insert</span><span style="color:#006600; font-weight:bold;">&#40;</span>make_pair&amp;lt;int, int&amp;gt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">4</span>, <span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> D.<span style="">insert</span><span style="color:#006600; font-weight:bold;">&#40;</span>make_pair&amp;lt;int, int&amp;gt;<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">5</span>, <span style="color:#800000;color:#800000;">6</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> MMap::<span style="">const_iterator</span> iter<span style="color:#006600; font-weight:bold;">&#40;</span>D.<span style="">begin</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> MMap::<span style="">const_iterator</span> end<span style="color:#006600; font-weight:bold;">&#40;</span>D.<span style="">end</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> for <span style="color:#006600; font-weight:bold;">&#40;</span>; iter != end; ++iter<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   cout &amp;lt;&amp;lt;iter-&amp;gt;first &amp;lt;&amp;lt;<span style="color:#CC0000;">" "</span> &amp;lt;&amp;lt;iter-&amp;gt;second &amp;lt;&amp;lt;std::<span style="">endl</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p>
印出<br />
2 2<br />
3 2<br />
4 3<br />
5 6<br />
1 10</p>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2009/07/sort-map-value.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace strtok Function</title>
		<link>http://evotalk.net/blog/2009/01/replace-strtok-function.html</link>
		<comments>http://evotalk.net/blog/2009/01/replace-strtok-function.html#comments</comments>
		<pubDate>Thu, 15 Jan 2009 03:39:06 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[程式設計]]></category>
		<category><![CDATA[cpp]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=1164</guid>
		<description><![CDATA[strtok is a non-thread safe function
在 unix 平台下有 strtok_r 可替代。
windows 需要實作一個
strtok_r  fnnction, reference General Programming Concepts:
Writing and Debugging Programs
view plain

CODE:




char *strsep&#40;char **stringp, const char *delim&#41;


&#123;


char* strtok_r&#40;char *  s1, const char *  s2,  char **  lasts&#41;


&#123;


  char *ret;


&#160;


  if &#40;s1 == NULL&#41;


    s1 = *lasts;


  while&#40;*s1 &#38;amp;&#38;amp; strchr&#40;s2, *s1&#41;&#41;


    ++s1;


  if&#40;*s1 == '\0'&#41;


    return NULL;


  ret [...]]]></description>
			<content:encoded><![CDATA[<p>strtok is a non-thread safe function<br />
在 unix 平台下有 strtok_r 可替代。<br />
windows 需要實作一個</p>
<p><strong>strtok_r  fnnction, reference <a href="http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.genprogc/doc/genprogc/writing_reentrant_thread_safe_code.htm" target="_blank">General Programming Concepts:<br />
Writing and Debugging Programs</a></strong></p>
<div class="igBar"><span id="lcode-5"><a href="#" onclick="javascript:showCodeTxt('code-5'); return false;">view plain</a></span></div>
<div class="shadow">
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-5">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">char *strsep<span style="color:#006600; font-weight:bold;">&#40;</span>char **stringp, const char *delim<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">char* strtok_r<span style="color:#006600; font-weight:bold;">&#40;</span>char *  s1, const char *  s2,  char **  lasts<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  char *ret;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  if <span style="color:#006600; font-weight:bold;">&#40;</span>s1 == NULL<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    s1 = *lasts;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  while<span style="color:#006600; font-weight:bold;">&#40;</span>*s1 &amp;amp;&amp;amp; strchr<span style="color:#006600; font-weight:bold;">&#40;</span>s2, *s1<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    ++s1;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  if<span style="color:#006600; font-weight:bold;">&#40;</span>*s1 == <span style="color:#CC0000;">'<span style="color:#000099; font-weight:bold;">\0</span>'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    return NULL;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  ret = s1;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  while<span style="color:#006600; font-weight:bold;">&#40;</span>*s1 &amp;amp;&amp;amp; !strchr<span style="color:#006600; font-weight:bold;">&#40;</span>s2, *s1<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    ++s1;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  if<span style="color:#006600; font-weight:bold;">&#40;</span>*s1<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    *s1++ = <span style="color:#CC0000;">'<span style="color:#000099; font-weight:bold;">\0</span>'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  *lasts = s1;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  return ret;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  return res;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
<p><strong>How to use ?</strong></p>
<div class="igBar"><span id="lcode-6"><a href="#" onclick="javascript:showCodeTxt('code-6'); return false;">view plain</a></span></div>
<div class="shadow">
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-6">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#include &amp;lt;stdio.<span style="">h</span>&amp;gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#include &amp;lt;string.<span style="">h</span>&amp;gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">int main<span style="color:#006600; font-weight:bold;">&#40;</span>int argc, char* argv<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> char sz<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#800000;color:#800000;">255</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> char* pc = NULL;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> char* pt = NULL;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> char *pointer;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> strcpy<span style="color:#006600; font-weight:bold;">&#40;</span>sz, <span style="color:#CC0000;">"#_ni__#hao"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> pt = sz;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> pc = strtok_r<span style="color:#006600; font-weight:bold;">&#40;</span>sz, <span style="color:#CC0000;">"#_<span style="color:#000099; font-weight:bold;">\n</span>"</span>, &amp;amp;pointer<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> while<span style="color:#006600; font-weight:bold;">&#40;</span>pc<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">  printf<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"%s<span style="color:#000099; font-weight:bold;">\n</span>"</span>, pc<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        pc= strtok_r<span style="color:#006600; font-weight:bold;">&#40;</span>NULL, <span style="color:#CC0000;">"#_<span style="color:#000099; font-weight:bold;">\n</span>"</span>, &amp;amp;pointer<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> printf<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"#######<span style="color:#000099; font-weight:bold;">\n</span>"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> strcpy<span style="color:#006600; font-weight:bold;">&#40;</span>sz, <span style="color:#CC0000;">"#_ni__#hao"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> pc = strtok<span style="color:#006600; font-weight:bold;">&#40;</span>sz, <span style="color:#CC0000;">"#_<span style="color:#000099; font-weight:bold;">\n</span>"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   while <span style="color:#006600; font-weight:bold;">&#40;</span>pc<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      printf<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"%s<span style="color:#000099; font-weight:bold;">\n</span>"</span>, pc<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">      pc = strtok<span style="color:#006600; font-weight:bold;">&#40;</span>NULL, <span style="color:#CC0000;">"#_<span style="color:#000099; font-weight:bold;">\n</span>"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"> return <span style="color:#800000;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2009/01/replace-strtok-function.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C List Files on Windows</title>
		<link>http://evotalk.net/blog/2008/12/c-list-file.html</link>
		<comments>http://evotalk.net/blog/2008/12/c-list-file.html#comments</comments>
		<pubDate>Wed, 03 Dec 2008 09:24:01 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[程式設計]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[file]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=459</guid>
		<description><![CDATA[c 列舉檔名
view plain

C++:




#include&#160; &#160;&#60;stdio.h&#62; 


#include&#160; &#160;&#60;io.h&#62; 


#include&#160; &#160;&#60;time.h&#62; 


&#160;


void main&#40;void&#41; 


&#123; 


&#160; &#160; struct&#160; &#160;_finddata_t&#160; &#160;c_file; 


&#160; &#160; long&#160; &#160;hFile; 


&#160;


&#160; &#160; if&#40;&#160; &#160;&#40;hFile = _findfirst&#40;&#160; &#160;"*.* ",&#160; &#160;&#38;c_file&#160; &#160;&#41;&#41; == -1L&#41; 


&#160; &#160; &#160; &#160; printf&#40;&#160; &#160;"No&#160; &#160;*.c&#160; &#160;files&#160; &#160;in&#160; &#160;current&#160; &#160;directory!n "&#160; &#160;&#41;; 


&#160; &#160; else 


&#160; &#160; &#123; 


&#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>c 列舉檔名</p>
<div class="igBar"><span id="lcpp-8"><a href="#" onclick="javascript:showCodeTxt('cpp-8'); return false;">view plain</a></span></div>
<div class="shadow">
<div class="syntax_hilite"><span class="langName">C++:</span>
<div id="cpp-8">
<div class="cpp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #339900;">#include&nbsp; &nbsp;&lt;stdio.h&gt; </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #339900;">#include&nbsp; &nbsp;&lt;io.h&gt; </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #339900;">#include&nbsp; &nbsp;&lt;time.h&gt; </span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">void</span> main<span style="color: #000000;">&#40;</span><span style="color: #0000ff;">void</span><span style="color: #000000;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0000ff;">struct</span>&nbsp; &nbsp;_finddata_t&nbsp; &nbsp;c_file; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0000ff;">long</span>&nbsp; &nbsp;hFile; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0000ff;">if</span><span style="color: #000000;">&#40;</span>&nbsp; &nbsp;<span style="color: #000000;">&#40;</span>hFile = _findfirst<span style="color: #000000;">&#40;</span>&nbsp; &nbsp;<span style="color: #666666;">"*.* "</span>,&nbsp; &nbsp;&amp;c_file&nbsp; &nbsp;<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> == -1L<span style="color: #000000;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span>&nbsp; &nbsp;<span style="color: #666666;">"No&nbsp; &nbsp;*.c&nbsp; &nbsp;files&nbsp; &nbsp;in&nbsp; &nbsp;current&nbsp; &nbsp;directory!n "</span>&nbsp; &nbsp;<span style="color: #000000;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0000ff;">else</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">do</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span>c_file.<span style="color: #00eeff;">attrib</span>&nbsp; &nbsp;&amp;&nbsp; &nbsp;_A_ARCH<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">printf</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">"%sn"</span>, c_file.<span style="color: #00eeff;">name</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">while</span> <span style="color: #000000;">&#40;</span>_findnext<span style="color: #000000;">&#40;</span>&nbsp; &nbsp;hFile,&nbsp; &nbsp;&amp;c_file&nbsp; &nbsp;<span style="color: #000000;">&#41;</span> == <span style="color: #0000dd;color:#800000;">0</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; _findclose<span style="color: #000000;">&#40;</span>&nbsp; &nbsp;hFile&nbsp; &nbsp;<span style="color: #000000;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2008/12/c-list-file.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Icon by File Type</title>
		<link>http://evotalk.net/blog/2008/12/get-icon-by-file-type.html</link>
		<comments>http://evotalk.net/blog/2008/12/get-icon-by-file-type.html#comments</comments>
		<pubDate>Tue, 02 Dec 2008 06:47:15 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[程式設計]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[ico]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=452</guid>
		<description><![CDATA[根據檔案的副檔名，取得 icon 圖案
view plain

C++:




// 傳入的 FileName 可為 &#34;.doc&#34; 、&#34;.pdf&#34;、&#34;.rar&#34; ....


void __fastcall TForm1::GetIcon&#40;AnsiString FileName&#41;


&#123;


   SHFILEINFO sfi;


   SHGetFileInfo&#40;


                  FileName.c_str&#40;&#41;,


                  FILE_ATTRIBUTE_NORMAL,


                  &#38;sfi,


                  sizeof&#40;SHFILEINFO&#41;,


                  SHGFI_ICON


                &#41;;


   TIcon* picon = [...]]]></description>
			<content:encoded><![CDATA[<p>根據檔案的副檔名，取得 icon 圖案</p>
<div class="igBar"><span id="lcpp-10"><a href="#" onclick="javascript:showCodeTxt('cpp-10'); return false;">view plain</a></span></div>
<div class="shadow">
<div class="syntax_hilite"><span class="langName">C++:</span>
<div id="cpp-10">
<div class="cpp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// 傳入的 FileName 可為 &quot;.doc&quot; 、&quot;.pdf&quot;、&quot;.rar&quot; ....</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">void</span> __fastcall TForm1::<span style="color: #00eeff;">GetIcon</span><span style="color: #000000;">&#40;</span>AnsiString FileName<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   SHFILEINFO sfi;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   SHGetFileInfo<span style="color: #000000;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                  FileName.<span style="color: #00eeff;">c_str</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                  FILE_ATTRIBUTE_NORMAL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                  &amp;sfi,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                  <span style="color: #0000dd;">sizeof</span><span style="color: #000000;">&#40;</span>SHFILEINFO<span style="color: #000000;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                  SHGFI_ICON</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   TIcon* picon = <span style="color: #0000dd;">new</span> TIcon<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   picon-&gt;Handle = sfi.<span style="color: #00eeff;">hIcon</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   Image1-&gt;Canvas-&gt;Pen-&gt;Color = clWhite;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   Image1-&gt;Canvas-&gt;Brush-&gt;Color = clWhite;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   Image1-&gt;Canvas-&gt;Rectangle<span style="color: #000000;">&#40;</span> <span style="color: #0000dd;color:#800000;">0</span>, <span style="color: #0000dd;color:#800000;">0</span>, <span style="color: #0000dd;color:#800000;">32</span>, <span style="color: #0000dd;color:#800000;">32</span> <span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   Image1-&gt;Canvas-&gt;Draw<span style="color: #000000;">&#40;</span> <span style="color: #0000dd;color:#800000;">0</span>, <span style="color: #0000dd;color:#800000;">0</span>, picon <span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   DestroyIcon<span style="color: #000000;">&#40;</span> sfi.<span style="color: #00eeff;">hIcon</span> <span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">   <span style="color: #0000dd;">delete</span> picon;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2008/12/get-icon-by-file-type.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C 和 C++ 中 struct 和 typedef struct 的區別</title>
		<link>http://evotalk.net/blog/2007/01/c-and-c-and-struct-in-the-difference-between-typedef-struct.html</link>
		<comments>http://evotalk.net/blog/2007/01/c-and-c-and-struct-in-the-difference-between-typedef-struct.html#comments</comments>
		<pubDate>Thu, 18 Jan 2007 06:24:31 +0000</pubDate>
		<dc:creator>asd</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[程式設計]]></category>
		<category><![CDATA[cpp]]></category>

		<guid isPermaLink="false">http://evotalk.net/blog/?p=320</guid>
		<description><![CDATA[轉貼自「計算機科學論壇 」
view plain

C++:




// 在C和C++有三種定義結構的方法。


typedef struct &#123;


int data;


int text;


&#125; S1;


&#160;


// 這種方法可以在c或者c++中定義一個S1結構


struct S2 &#123;


int data;


int text;


&#125;;


&#160;


// 這種定義方式只能在C++中使用，而如果用在C中，那麼編譯器會報錯


struct &#123;


int data;


int text;


&#125; S3;


&#160;


//這種方法並沒有定義一個結構，而是定義了一個s3的結構變量，編譯器會為s3內存。


void main&#40;&#41;


&#123;


S1 mine1; // OK , S1 是一個類型


S2 mine2; // OK, S2 是一個類型


S3 mine3; // OK, S3 不是一個類型


S1.data = 5; // ERROR S1 是一個類型


S2.data = 5; // ERROR S2 是一個類型


S3.data = 5; // OK S3是一個變量


&#125;


&#160;


// 另外，對與在結構中定義結構本身的變量也有幾種寫法


struct S6 &#123;


S6* [...]]]></description>
			<content:encoded><![CDATA[<p>轉貼自「<a href="http://www.ieee.org.cn/dispbbs.asp?boardID=61&amp;ID=41942">計算機科學論壇</a> 」</p>
<div class="igBar"><span id="lcpp-12"><a href="#" onclick="javascript:showCodeTxt('cpp-12'); return false;">view plain</a></span></div>
<div class="shadow">
<div class="syntax_hilite"><span class="langName">C++:</span>
<div id="cpp-12">
<div class="cpp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// 在C和C++有三種定義結構的方法。</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">typedef</span> <span style="color: #0000ff;">struct</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">int</span> data;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">int</span> text;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> S1;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// 這種方法可以在c或者c++中定義一個S1結構</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">struct</span> S2 <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">int</span> data;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">int</span> text;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// 這種定義方式只能在C++中使用，而如果用在C中，那麼編譯器會報錯</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">struct</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">int</span> data;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">int</span> text;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> S3;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">//這種方法並沒有定義一個結構，而是定義了一個s3的結構變量，編譯器會為s3內存。</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">void</span> main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">S1 mine1; <span style="color: #ff0000;">// OK , S1 是一個類型</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">S2 mine2; <span style="color: #ff0000;">// OK, S2 是一個類型</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">S3 mine3; <span style="color: #ff0000;">// OK, S3 不是一個類型</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">S1.<span style="color: #00eeff;">data</span> = <span style="color: #0000dd;color:#800000;">5</span>; <span style="color: #ff0000;">// ERROR S1 是一個類型</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">S2.<span style="color: #00eeff;">data</span> = <span style="color: #0000dd;color:#800000;">5</span>; <span style="color: #ff0000;">// ERROR S2 是一個類型</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">S3.<span style="color: #00eeff;">data</span> = <span style="color: #0000dd;color:#800000;">5</span>; <span style="color: #ff0000;">// OK S3是一個變量</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// 另外，對與在結構中定義結構本身的變量也有幾種寫法</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">struct</span> S6 <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">S6* ptr;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// 這種寫法只能在C++中使用</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">typedef</span> <span style="color: #0000ff;">struct</span> <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">S7* ptr;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> S7;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">// 這是一種在C和C++中都是錯誤的定義</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">//如果在C中，我們可以使用這樣</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0000ff;">typedef</span> <span style="color: #0000ff;">struct</span> tagS8<span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">tagS8 * ptr;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> S8; </div>
</li>
</ol>
</div>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://evotalk.net/blog/2007/01/c-and-c-and-struct-in-the-difference-between-typedef-struct.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
