<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://www.gentoo-zh.org/extern.php?action=feed&amp;tid=344&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Gentoo中文社区 / C 练习实例35]]></title>
		<link>https://www.gentoo-zh.org/viewtopic.php?id=344</link>
		<description><![CDATA[C 练习实例35 最近发表的帖子。]]></description>
		<lastBuildDate>Mon, 29 Aug 2022 07:16:16 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[C 练习实例35]]></title>
			<link>https://www.gentoo-zh.org/viewtopic.php?pid=350#p350</link>
			<description><![CDATA[<p>题目：字符串反转，如将字符串 &quot;<a href="http://www.runoob.com" rel="nofollow">www.runoob.com</a>&quot; 反转为 &quot;moc.boonur.www&quot;。</p><p>程序分析：无。 </p><div class="codebox"><pre class="vscroll"><code>#include &lt;stdio.h&gt;
 
 
void reverse(char* s)
{
    // 获取字符串长度
    int len = 0;
    char* p = s;
    while (*p != 0)
    {
        len++;
        p++;
    }
    
    // 交换 ...
    int i = 0;
    char c;
    while (i &lt;= len / 2 - 1)
    {
        c = *(s + i);
        *(s + i) = *(s + len - 1 - i);
        *(s + len - 1 - i) = c;
        i++;
    }
}
 
int main()
{
    char s[] = &quot;www.runoob.com&quot;;
    printf(&quot;&#039;%s&#039; =&gt;\n&quot;, s);
    reverse(s);           // 反转字符串
    printf(&quot;&#039;%s&#039;\n&quot;, s);
    return 0;
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (batsom)]]></author>
			<pubDate>Mon, 29 Aug 2022 07:16:16 +0000</pubDate>
			<guid>https://www.gentoo-zh.org/viewtopic.php?pid=350#p350</guid>
		</item>
	</channel>
</rss>
