﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-静水流深，向前无语</title><link>http://www.cppblog.com/bourne/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 12 Apr 2026 08:09:00 GMT</lastBuildDate><pubDate>Sun, 12 Apr 2026 08:09:00 GMT</pubDate><ttl>60</ttl><item><title>Microsoft .NET完全介绍</title><link>http://www.cppblog.com/bourne/archive/2006/09/28/13082.html</link><dc:creator>Bourne</dc:creator><author>Bourne</author><pubDate>Thu, 28 Sep 2006 03:03:00 GMT</pubDate><guid>http://www.cppblog.com/bourne/archive/2006/09/28/13082.html</guid><wfw:comment>http://www.cppblog.com/bourne/comments/13082.html</wfw:comment><comments>http://www.cppblog.com/bourne/archive/2006/09/28/13082.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bourne/comments/commentRss/13082.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bourne/services/trackbacks/13082.html</trackback:ping><description><![CDATA[
		<font size="2">本文给出了一个对Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">和Microsoft's </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务平台的总体介绍以及使用它们的好处。同时我们还将举例说明</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">是如何改变终端用户和商业的计算模式。 <br />   <br />  　　在本文中我们不想涉及到很精深的技术，任何稍微懂一点电脑和Internet知识的人都可以理解本篇的内容。Micorosoft还为那些希望掌握</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">的公司执行官、IT领导和程序员们 <br />  提供了更多的资源。 <br />   <br />  　　什么是Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">? <br />   <br />  　　Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">是Microsoft的</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务平台。</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">包含了建立和运行基于</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2">的</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">所需要的全部部件。 <br />   <br />  　　Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">解决了下面这些当今</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">开发中的一些核心问题： <br />   <br />  　　●互操作性(Interoperability)、集成性(Integration)和应用程序的可扩展性(extensibility)太难实现而且代价很高。Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">依靠</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2">(一个由World Wide Web Consortium(W3C)管理的开放标准)消除了数据共享和</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">集成的障碍。 <br />   <br />  　　●无数具有相当竞争力的私有</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">技术使得</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">的集成变得非常复杂。而Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">建立在一个开放的标准上，它包含了所有</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html">
				<font size="2">编程</font>
		</a>
		<font size="2">语言。 <br />   <br />  　　●当终端用户使用</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">时，他们总觉得不够简便。有时甚至感到很沮丧，因为他们无法在程序之间方便地共享数据或是无法对能访问的数据进行操作。</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2">使数据交换变得容易了，并且</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">可以使得用户只要一得到数据就能对它们进行操作。 <br />   <br />  　　●终端用户们在使用Web的时候，无法对自己的个人信息和数据进行控制，这导致了个人隐私和安全泄漏问题。而Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">提供了一套服务，使用户可以管理他们的个人信息，并且控制对这些信息的访问。 <br />   <br />  　　●.COM公司和Web站点开发者们很难为用户们提供足够的有价值的数据，至少有一部分原因是由于他们的应用程序和服务无法很好地和其他程序和服务合作，只是一个不和外界连接的信息孤岛。而Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">的设计宗旨就是为了使来自于多个站点和公司的数据或服务能够整合起来。 <br />   <br />  　　如同MS-DOS和Windows一样，</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">将大大改变我们的计算领域。MS-DOS使得个人电脑在商业和家庭中广为接受；Windows增强了用户的图形界面，使其成为首选的与</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">交互方式，最终使得图形界面成为个人电脑的主流。而</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">则要把</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务变成日后的主流计算模式。 <br />   <br />  　　</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务是建立在</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2">数据交换基础上的</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">模型，它帮助应用程序、服务和设备一起工作。用</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2">进行共享的数据，彼此之间独立，但同时又能够松耦合地连接到一个执行某特定任务的合作组。 <br />   <br />  　　想了解</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务如何工作，最方便的方法就是把它和拼装</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/game/Index.html">
				<font size="2">游戏</font>
		</a>
		<font size="2">作比较。</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务和拼装</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/game/Index.html">
				<font size="2">游戏</font>
		</a>
		<font size="2">的拼块一样是一些独立的单元。后者用一个标准的方法相互咬合在一起，</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务与这类似，但它是通过</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> message实现相互交互的。当你把拼块拼在一起时，你就得到了一个对象：一幢房子、一艘船或一架飞机。同样，当你把</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务结合在一起时，你就得到了一个完成某特定任务的</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">解决方案。同一拼块可以用在很多不同对象中，而一个</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务同样也可以用在不同的方案组中，作为不同任务解决方案的一个组成部分。 <br />   <br />  　　</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务使开发者能够对他们所要的程序的来源进行选择，可以自己创建或购买程序的功能块；同样也可以选择是让自己的方案使用其他的</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务，还是让其他的程序使用自己的服务。这意味着一个公司不必为了给客户一个完整的解决方案而不得不提供方案的每一个组成部分。 <br />   <br />  　　</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务除了个服务相互之间独立以外，对访问它们的设备而言也是独立的。与独立应用程序不同的是，</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务并没有束缚于某一特定的</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html">
				<font size="2">编程</font>
		</a>
		<font size="2">语言或商业应用程序或者是某一在线服务。这给了终端用户足够的自由，使其可以使用任何访问设备，从台式电脑到移动电话都可以。 <br />   <br />  　　</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">战略 <br />   <br />  　　Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">程序员们设计编写的是</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务，而不是服务器或客户端的独立应用程序。他们把这些服务组合成松耦合，相互协作的</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">群，</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务之间使用</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> messaging进行通讯。为了做到这一点，程序员需要： <br />   <br />  　　1.一个</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html">
				<font size="2">软件</font>
		</a>
		<font size="2">平台，用于建立一种新的完整的个人用户经验。 <br />   <br />  　　2.一个</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html">
				<font size="2">编程</font>
		</a>
		<font size="2">模型和工具，用以建立和整合</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务。 <br />   <br />  　　3.一套能为应用程序和服务提供基础的可</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html">
				<font size="2">编程</font>
		</a>
		<font size="2">的服务 <br />   <br />  　　Microsoft的</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">战略就瞄准了这三点。 <br />   <br />  　　</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">包括： <br />   <br />  　　●</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">平台，这是一套</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html">
				<font size="2">编程</font>
		</a>
		<font size="2">工具和基本构架，用来创建、发布、管理和整合</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务 <br />   <br />  　　●</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">体验，这是终端用户用以和</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">交互的手段<br /><br /></font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">平台 <br />   <br />  　　Microsoft的平台是由用于创建和运行</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务组成的。它包含了下面四个组件： <br />   <br />  　　</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">框架和Visual Studio</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">:这些是开发人员用来生成</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务的工具。</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">框架是Microsoft </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">平台核心中的一套</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html">
				<font size="2">编程</font>
		</a>
		<font size="2">接口；Visual Studio</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">是一套多语言系列的 <br />  </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html">
				<font size="2">编程</font>
		</a>
		<font size="2">工具。 <br />   <br />  　　服务器基本结构(Server Infrastructure): </font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">的服务器基本结构是一系列用于生成、发布和操作</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2"> Web服务的基础程序，包括Windows和各种</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html">
				<font size="2">.NET</font>
		</a>
		<font size="2">企业服务器。主要的技术包括对</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2">、scale-out及跨程序和服务的商务流程(business process orchestration)的支持。这些服务器包括有： <br />   <br />  　　●Application Center 2000，用于scale-out solutions <br />   <br />  　　●BizTalk Server 2000，用于创建和管理基于</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html">
				<font size="2">XML</font>
		</a>
		<font size="2">的跨程序和服务的商务流程(business process orchestration across applications and services) <br />   <br />  　　●Host Integration Server 2000，用来访问主机上的数据和应用程序 <br />   <br />  　　●Mobile Information 2001 Server，使移动设备，比如移动电话，也能使用这些应用程序 <br />   <br />  　　●</font>
		<a class="Channel_KeyLink" href="http://www.hur.cn/web/db/Mssql/Index.html">
				<a class="Channel_KeyLink" href="http://www.hur.cn/web/db/Mssql/Index.html">
						<font size="2">SQL</font>
				</a>
				<font size="2"> Server</font>
		</a> 2000储存和检索结构化的<a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2">数据 <br />   <br />  　　Building Block Services: Building Block Services是一套以用户为中心的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务，它把用户数据的控制权从应用程序移到了用户手上，使Web有了一个翻天覆地的变化，做到了程序、服务和设备之间的简单性及一致性，这保证了所有的交易都必须得到用户的同意。这些服务包含了Passport(用于用户身份验证)、服务之间的消息传递、文件存储、用户个性设置的管理、日历管理和其他一些功能。Microsoft将在那些对</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">基本结构起至关重要作用的领域内提供一些块构建服务(building block services)。大量的合作伙伴和开发商将对这些块构建服务作重要的扩展。 <br />   <br />  　　智能设备(smart device): </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">利用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">使智能设备，诸如手提电脑、轻便电话、</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/game/Index.html"><font size="2">游戏</font></a><font size="2">操纵台等都能够在</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">世界中得以使用。 <br />   <br />  　　一个智能设备应该： <br />   <br />  　　●对用户要智能：能根据用户的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">身份、档案(profile)和有关数据简化用户的工作；另外要对用户的存在足够的智能，能根据你的在与不在对通知(notification)作出调整。 <br />   <br />  　　●对网络要智能：负责带宽的限制；支持应用程序的在线和线下两种使用模式；知道有哪些有效的服务。 <br />   <br />  　　●对信息要智能：能在任何地方、任何时间访问、分析和操作数据。 <br />   <br />  　　●对其他的设备要智能：能发现和报告其他智能设备、服务和Internet的存在；知道如何为其他设备提供服务；能够灵活方便地从PC上访问信息。 <br />   <br />  　　●对</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">和服务要智能：能根据表单的情况，最恰当地表现应用和数据；为终端用户提供合适的输入方法和连接；用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2">、SOAP和UDDI来使用Web服务；对开发者来说，要具有可</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html"><font size="2">编程</font></a><font size="2">性和扩展性 <br />   <br />  　　Microsoft的一些</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">使能够在智能设备上运行的，它们包括Windows XP、Windows Me、Windows CE、嵌入式Windows、</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">框架以及</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2"> Compact框架。 <br />   <br />  　　</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验(</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2"> experiences) <br />   <br />  　　终端用户是通过</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验访问</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务的，这和现有的独立应用程序有点类似，但在下列这些重要的方面是不同的： <br />   <br />  　　●</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验可使用于多种设备我们无需为可能使用的每一个设备编写一个不同</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务和不同的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验，</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验能够读取用户选取设备的特征，给出一个恰当界面。 <br />   <br />  　　●</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验使用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务当</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验连入网络后就能有效地利用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务为用户带来额外的价值，以更好地解决问题。 <br />   <br />  　　●</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验是以用户为中心的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验的焦点在终端用户，使用基于身份验证的块构建服务来为用户验证、参数设定、通知机制和用户数据提供服务。因为用户数据是由块构建服务管理的，而不是应用程序本身，所以用户就能控制他们自己的数据，能保障它的正确性，并且可以在不同的程序和服务之间协调数据。 <br />   <br />  　　Microsoft正在使最受欢迎的四个产品过渡到</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验。Microsoft Office XP为用户提供</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验方面跨出了第一步。另外，MSN，包括MSN Explorer本地客户端的使用，正在创建一个基于消费者的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验。Microsoft bCentral的小型商务入口(business portal)正努力为小型事务(比如商品目录管理)提供必要的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务，同时也使用一些重要的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务(比如eBay)。Visual Studio开发系统将为开发者们提供</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验，可以在这些开发工具中直接得到MSDN信息。 <br />   <br />  　　</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">的好处 <br />   <br />  　　Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">为程序员、商业领导、IT部门以及消费者带来了很多好处。 <br />   <br />  　　●相对来说，程序员是比较缺乏的，雇用的费用也很高。然而Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">使</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html"><font size="2">编程</font></a><font size="2">工作变得更加容易，开发投资的回报率也趋最大化。开发者们可以创建能重用的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务，而不再是一个单一的程序；这些Web服务易于</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html"><font size="2">编程</font></a><font size="2">和调试，彼此之间相互独立，通过</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> message通讯及合作。所以对某一个服务的修改不会影响到其他的服务。 <br />   <br />  　　由于</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务可以被很多</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验共同使用，所以对一个服务模块的有效更新，也即更新了所有使用这个模块的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验。任何</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html"><font size="2">编程</font></a><font size="2">语言都可以用来编写</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务(如：C、</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/cc/Index.html"><font size="2">C++</font></a><font size="2">、Visual Basic、COBOL、Perl、Python和Java等)，所以你的程序员可以选择他们最熟悉的语言来</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html"><font size="2">编程</font></a><font size="2">，这大大提高了开发效率。更值得一体的是，他们并没有因使用了不同的语言而失去跨服务或跨组件的调试能力。 <br />   <br />  　　●Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">减少了程序员要写的代码量。一个</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务能适用于所以的设备，不必再去为每一个设备编写一个不同的版本。另外，将显示特性与</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验分开以便以后加入新的接口技术，比如语音或手写识别，而不必去重写程序。 <br />   <br />  　　●Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">开创了全新的商业模型，它使得一个公司可以用多种方法来把自己的技术商品化。据个例子来说，一个通讯公司可以使用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务的方式提供语音信件和呼叫者ID的访问，让用户从一个即时消息程序、电子邮件或用户所选的其他信息编译器中访问到上述信息。技术提供商可以把他们现有的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">包转变为</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务，并把这些服务出售给需要这些功能第三方，或是给</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验提供商，用以构建新的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">包。<br /><br />●Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">允许IT部门使用其他提供商的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务，减少内部研发的开销，并能提高工作效率。 <br />   <br />  　　●Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">对"用户界面友好"作了重新定义。终端用户能够徜徉于一个智能化的、个性化的Internet，它能记住用户的个人设置，并在适当的时候，向用户使用的智能设备上发送适当的数据。<br /><br /></font><table class="main_tdbg_575" style="WORD-BREAK: break-all" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"><tbody><tr><td colspan="2"><table><tbody><tr><td><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">如何改变计算 <br />   <br />  　　Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">将从根本上改变我们的思考和使用电脑的方式。目前"服务器"和"桌面电脑"这两种概念占据了计算领域的统治地位。然而Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">是一种分布式计算范例，它没有了传统上的服务器和桌面电脑的区别，取而代之的是，计算的处理被放在最合适的地方进行，可能是服务 <br />  器，或是PC，也有可能是手提电脑以及其他智能设备。这就是智能计算。 <br />   <br />  　　</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">的计算模型对商务和终端用户都产生了重要影响，但方法不同。对终端用户来说，这个新计算模式更具个性化、综合程度更高，会给他们带来一种史无前例的新体验。对商务来说，这个模式改变了制造和销售</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">的方法，使IT成为一个公司成功的重要贡献者，并建立起新的商务模型。 <br />   <br />  　　对终端用户的改变 <br />   <br />  　　这里有一个例子，说明了</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验是如何对一个终端用户产生影响的。 <br />   <br />  　　Bob，一个不安的商务旅行者，在芝加哥下了飞机，突然想起他竟忘了带上他的那部智能电话。这下完了，没了这电话他无法知道晚宴在哪里进行，无法知道原本打算在晚宴上见面的人的电话号码，更惨的是，他无法在这个关键的会议之前再看一下重要的文件。但不用急，他从机场的租了一部智能电话，插入了自己的智能卡。很快通过内置的Internet连接，各种相关的重要数据全部被下载了下来，现在他能访问他的所有信息，不光是日程安排和电话簿，还有所有通常用他的PC机能访问到的所以文件。 <br />   <br />  　　不幸的是，他在离开机场时不小心在自动扶梯上绊了一跤，脚踝严重扭伤，这个月这已经是第二次了。无奈，他强忍疼痛要求电话接Roger医生的办公室，听电话的是接待员Mildred小姐。Bob通过电话确认了自己的身份，他授权于Mildred小姐，让她访问自己的所在位置和其他一些信息，以便使她可以在附近找一家整形外科诊所。Mildred能够知道哪家诊所正在营业，有多远，是否接受Bob的保险。Bob所要做的就是轻按电话上的按钮授权给她，Mildred在找到诊所后便会和医生约时间。 <br />   <br />  　　与Mildred通话结束后，Bob用他的智能电话访问出租车服务，查找离他最近的出租车，并确认目的地。接下来Bob只需爬进车内，轻按电话的显示屏确认支付的费用即可。 <br />   <br />  　　从用户角度来讲，</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">提供的好处即超过了现在的独立的程序，也胜过了纯粹的Web站点。</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务拥有传统的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">功能，如创建文档、计算数字、存储数据等。而且在下线后也能提供服务，比如呼叫出租车，这并不需要CPU的参与。 <br />   <br />  　　从上面的例子我们可以看到，</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务使终端用户得到了更为个性化的、综合性的体验，同时便捷也是</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">给我们带来的一大好处。 <br />   <br />  　　对企业的改变 <br />   <br />  　　Bob那不走运的商务旅行结束了，他蹒跚地回到了家(虽然那个晚宴非常成功，但现在他不得不面对六个星期的身体治疗)。接下来，Bob要提交费用报告。他拿出了他的PDA，验明身份后，PDA列出了其信用卡上的支付纪录。他标出了与这次芝加哥之行有关的费用，至于那些止痛药和寄私人信件的费用，他标为个人开销。信用卡公司将为其生成必要的账单。 <br />   <br />  　　因为Bob标记了一些个人费用，所以信用卡公司将根据他指定的方法为Bob生成一张个人帐单。在这个例子中，Bob使用的是直接从他银行账号中提钱的方法，但同时他也要一份药费开支报告的硬拷贝。根据他的选择，信用卡公司会Email发给他一个PDF文档，Bob只需将它打印出来即可。 <br />   <br />  　　对于那些业务上的开支，信用卡公司会给Bob的公司发出一张电子帐单，它被送到公司的会计部门，由公司会计Chris来处理。电子帐单到达时，Chris会收到一封自动生成的Email，随后他登录会计系统打开这份帐单。他仔细检查每一笔费用，没问题后，他进行支付，这也就是授权将一笔金从公司的账户转移到信用卡公司的账户上。 <br />   <br />  　　从企业角度讲，</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">能够自动地处理很多任务，节约了员工的大量时间。当用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2">将系统和</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务连接起来后，数据交换变得非常方便，数据处理也变得轻而易举。在这个例子中，员工Bob和Chris分别只要单击一下"同意"和启动一个事务处理，无需花大量的时间去填写报销单或是往会计系统中手工录入数据，一切都变得非常之简单。 <br />   <br />  　　对企业和企业终端用户来说，</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">预示这些从</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务衍生出来的应用程序有着很强的个性化和高度的整合性的特点，同时它们适用于各种智能设备，具有相当的灵活性。 <br />   <br />  　　什么东西没有变 <br />   <br />  　　尽管Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">给计算带来了一些翻天覆地的变化，但还有很多东西依然没有改变. <br />   <br />  　　●终端用户将依然使用熟悉的界面，就像</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验中的Microsoft Office一样。这可以减少再培训的开支，也意味着用户可以马上开始使用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">。 <br />   <br />  　　●</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/hardware/Index.html"><font size="2">硬件</font></a><font size="2">上运行的还是象Windows、Unix、Windows CE和Palm OS一样的操作系统。实际上，</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">增加了</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">的运行场所，但同时减少了开发的负担。由于</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务只使用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2">与设备通信，所以任何智能设备都可以享用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务。 <br />   <br />  　　●对程序员来说，他们依然可以使用他们原先熟悉的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html"><font size="2">编程</font></a><font size="2">语言。</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">平台借助于</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">框架的公共语言运行时间库(CLR)使得用不同语言开发的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务之间也可以相互操作。有没有</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验问题不大，你依旧可以用Visual Basic、Java、甚至是COBOL创建</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务。这种对</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html"><font size="2">编程</font></a><font size="2">语言的中立性意味着不用为了进入</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">世界而抛弃已有的投资。 <br />   <br />  　　●原先系统无需被替换。一部分的Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">产品就是为了能方便地将现有的系统整合到新，的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务和</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验中去而设计的。Host Integration Server就是个例子，它简化了对主机的访问。再比如就是BizTalk Server,它管理的商务流程(business process orchestration)包括了对现有系统和数据格式的支持，并会执行一些必要的转换，将数据转成</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2">。 <br />   <br />  　　　所以这种下一代的分布式计算是建立在目前这一代基础上的。Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">不是我们所想象的那样，对现在的应用</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">作大规模的替换，而是一个自然的进化过程，在原先的技术孤岛之间建立了协作关系，协同工作能力逐渐加强，我们也将从中受益无穷。 <br />   <br />  　　总结 <br />   <br />  　　Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">是Microsoft的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务的平台。这是下一代的Internet计算模型，各个</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务之间彼此是松耦合的，通过</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2">进行通讯，协同完成某一特定的任务。Microsoft </font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">战略提供了一个用以建立新</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/Article/software/Index.html"><font size="2">软件</font></a><font size="2">平台、一个</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html"><font size="2">编程</font></a><font size="2">模型、用以建立和整合</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/webemp/XML/Index.html"><font size="2">XML</font></a><font size="2"> Web服务的工具以及一套可</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/Index.html"><font size="2">编程</font></a><font size="2">的Web接口。 <br />   <br />  　　现在我们正处于向</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">转变的过程中。Microsoft已经宣布了</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">框架的第一个部分--</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">平台、Visual Studio</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">和一些块构建服务以及最初的</font><a class="Channel_KeyLink" href="http://www.hur.cn/web/program/net/Index.html"><font size="2">.NET</font></a><font size="2">体验。Microsoft在今年和明年中将会提供更多的工具和服务。</font></td></tr><p><font size="2"></font></p><p align="center"><font color="red"><b><font size="2">[1]</font></b></font><font size="2"></font></p><p></p><p><font size="2"></font></p></tbody></table></td></tr><!--频道首页中间广告一--><tr valign="center" align="middle"><td class="main_ArticleSubheading" style="WORD-BREAK: break-all" colspan="2"><font size="2"><script language="javascript" src="/web/AD/200511/5.js"></script></font></td></tr><!--频道中部广告1--></tbody></table><img src ="http://www.cppblog.com/bourne/aggbug/13082.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bourne/" target="_blank">Bourne</a> 2006-09-28 11:03 <a href="http://www.cppblog.com/bourne/archive/2006/09/28/13082.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>语言专题——标准库</title><link>http://www.cppblog.com/bourne/archive/2006/07/28/10629.html</link><dc:creator>Bourne</dc:creator><author>Bourne</author><pubDate>Fri, 28 Jul 2006 02:35:00 GMT</pubDate><guid>http://www.cppblog.com/bourne/archive/2006/07/28/10629.html</guid><wfw:comment>http://www.cppblog.com/bourne/comments/10629.html</wfw:comment><comments>http://www.cppblog.com/bourne/archive/2006/07/28/10629.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/bourne/comments/commentRss/10629.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bourne/services/trackbacks/10629.html</trackback:ping><description><![CDATA[原型：extern void *memcpy(void *dest, void *src, unsigned int count);<br /><br />用法：#include &lt;string.h&gt;<br /><br />功能：由src所指内存区域复制count个字节到dest所指内存区域。<br /><br />说明：src和dest所指内存区域不能重叠，函数返回指向dest的指针。<br /><br />举例：<br /><br />// memcpy.c<br /><br />#include &lt;syslib.h&gt;<br />#include &lt;string.h&gt;<br /><br />main()<br />{<br />char *s="Golden Global View";<br />char d[20];<br /><br />clrscr();<br /><br />memcpy(d,s,strlen(s));<br />d[strlen(s)]=0;<br />printf("%s",d);<br /><br />getchar();<br />return 0;<br />}<br /><br />原型：extern char *strchr(char *s,char c);<br /><br />用法：#include &lt;string.h&gt;<br /><br />功能：查找字符串s中首次出现字符c的位置<br /><br />说明：返回首次出现c的位置的指针，如果s中不存在c则返回NULL。<br /><br />举例：<br /><br /><br />// strchr.c<br /><br />#include &lt;syslib.h&gt;<br />#include &lt;string.h&gt;<br /><br />main()<br />{<br />char *s="Golden Global View";<br />char *p;<br /><br />clrscr();<br /><br />strchr(s,'V');<br />if(p)<br />printf("%s",p);<br />else<br />printf("Not Found!");<br /><br />getchar();<br />return 0;<br />}<br /><br /><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">1 </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">复制</span><span lang="EN-US"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">char* strcpy (char *s1, const char *s2);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将字符串</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">复制到</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指定的地址</span><span lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">char* strncpy (char *s1, const char *s2, size_t len);<br />void* <span style="mso-spacerun: yes"> </span>memcpy (void *s1, const void *s2, size_t len);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的前</span><span lang="EN-US">len</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个字符</span><span lang="EN-US">(</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">字节</span><span lang="EN-US">)</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">复制到</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中指定的地址</span><span lang="EN-US">, </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不加</span><span lang="EN-US">'\0'<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">void* memmove (void *s1, const void *s2, size_t len);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当源单元和目的单元缓冲区交迭时使用</span><span lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">size_t strxfrm (char *s1, const char *s1, size_t len);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">根据程序当前的区域选项</span><span lang="EN-US">, </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的前</span><span lang="EN-US">len</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个字符</span><span lang="EN-US">(</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">字节</span><span lang="EN-US">)</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">复制到</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中指定的地址</span><span lang="EN-US">, </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不加</span><span lang="EN-US">'\0'<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><br />2 </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">连接</span><span lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">char* strcat (char *s1, const char *s2);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将字符串</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">连接到</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">尾部</span><span lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">char* strncat (char *s1, const char *s2, size_t len);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将字符串</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的前</span><span lang="EN-US">len</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个字符连接到</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">尾部</span><span lang="EN-US">, </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不加</span><span lang="EN-US">'\0'<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><br />3 </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">比较</span><span lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">int strcmp (const char *s1, const char *s2);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">比较字符串</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span><span lang="EN-US">s2<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">int strncmp (const char *s1, const char *s2, size_t len);<br />int <span style="mso-spacerun: yes"> </span>memcmp (const void *s1, const void *s2, size_t len);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的前</span><span lang="EN-US">len</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个字符</span><span lang="EN-US">(</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">字节</span><span lang="EN-US">)</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">作比较</span><span lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US">int strcoll (const char *s1, const char *s2);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">根据程序当前的区域选项中的</span><span lang="EN-US">LC_COLLATE, </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">比较字符串</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</span><span lang="EN-US">s2<o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><br />4 </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">查找</span><span lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><font size="3">char* strchr (const char *s, int ch);<br />void* memchr (const void *s, int ch, size_t len);<br /></font><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span><span lang="EN-US">s</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中查找给定字符</span><span lang="EN-US">(</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">字节值</span><span lang="EN-US">)ch</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第一次出现的位置</span><span lang="EN-US"><o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span lang="EN-US">char* <b><span style="BACKGROUND: #ffff66; COLOR: black">strrchr</span></b> (const char *s, int ch);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在串</span><span lang="EN-US">s</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中查找给定字符</span><span lang="EN-US">ch</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最后一次出现的位置</span><span lang="EN-US">, r</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">表示从串尾开始</span><span lang="EN-US"><o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span lang="EN-US">char* strstr (const char *s1, const char *s2);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在串</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中查找指定字符串</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第一次出现的位置</span><span lang="EN-US"><o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span lang="EN-US">size_t strspn (const char *s1, const char *s2);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中第一个在</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中不存在的字符的索引</span><span lang="EN-US">(find_first_not_of)<o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span lang="EN-US">size_t strcspn (const char *s1, const char *s2);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中第一个也在</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中存在的字符的索引</span><span lang="EN-US">(find_first_of)<o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span lang="EN-US">char* strpbrk (const char *s1, const char *s2);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与</span><span lang="EN-US">strcspn</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类似</span><span lang="EN-US">, </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">区别是返回指针而不是索引</span><span lang="EN-US"><o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span lang="EN-US">char* strtok (char *s1, const char *s2);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">从串</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中分离出由串</span><span lang="EN-US">s2</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中指定的分界符分隔开的记号</span></font><font size="3"><span lang="EN-US">(token)<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第一次调用时</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为需分割的字串</span><span lang="EN-US">, </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">此后每次调用都将</span><span lang="EN-US">s1</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">置为</span></font><font size="3"><span lang="EN-US">NULL,<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">每次调用</span><span lang="EN-US">strtok</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回一个记号</span><span lang="EN-US">, </span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">直到返回</span><span lang="EN-US">NULL</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为止</span><span lang="EN-US"><o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><br /><font size="3">5 </font></span><font size="3"><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">其他</span><span lang="EN-US"><o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span lang="EN-US">size_t strlen (const char *s);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">求字符串</span><span lang="EN-US">s</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的长度</span><span lang="EN-US"><o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span lang="EN-US">void* memset (void *s, int val, size_t len);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">将从</span><span lang="EN-US">s</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开始的</span><span lang="EN-US">len</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个字节置为</span><span lang="EN-US">val<o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><font size="3"><span lang="EN-US">char* strerror (int errno);<br /></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回指向错误信息字符串的指针</span><span lang="EN-US"><o:p></o:p></span></font></p><p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt"><span lang="EN-US"><font size="3"><span style="mso-spacerun: yes"> </span><o:p></o:p></font></span></p><font size="3"><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">source: </span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'">《</span><b><span lang="EN-US" style="FONT-SIZE: 10.5pt; BACKGROUND: #a0ffff; COLOR: black; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">C</span></b><span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"> &amp; <b><span style="BACKGROUND: #a0ffff; COLOR: black">C</span></b>++ Code Capsules</span><span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-bidi-font-family: 'Times New Roman'">》</span></font></span><img src ="http://www.cppblog.com/bourne/aggbug/10629.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bourne/" target="_blank">Bourne</a> 2006-07-28 10:35 <a href="http://www.cppblog.com/bourne/archive/2006/07/28/10629.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>KMP字符串匹配算法C语言实现</title><link>http://www.cppblog.com/bourne/archive/2006/07/05/9472.html</link><dc:creator>Bourne</dc:creator><author>Bourne</author><pubDate>Wed, 05 Jul 2006 15:48:00 GMT</pubDate><guid>http://www.cppblog.com/bourne/archive/2006/07/05/9472.html</guid><wfw:comment>http://www.cppblog.com/bourne/comments/9472.html</wfw:comment><comments>http://www.cppblog.com/bourne/archive/2006/07/05/9472.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/bourne/comments/commentRss/9472.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bourne/services/trackbacks/9472.html</trackback:ping><description><![CDATA[
		<p>＃i nclude &lt;stdio.h&gt; <br />＃i nclude &lt;stdlib.h&gt;<br />＃i nclude &lt;string.h&gt;<br />＃i nclude &lt;time.h&gt; </p>
		<p>//获得prefix数组 <br />int* GetPrefixValue(char* strPattern, int iPatternLen)<br />{<br />    int i, j; /* i runs through the string, j counts the hits*/<br />    int* prefix = (int*)malloc(iPatternLen*sizeof(int));<br />    <br />    i = 1; j = 0;<br />    prefix[0] = 0; <br />    <br />    while(i&lt;iPatternLen)<br />    {<br />        if(strPattern[i] == strPattern[j])<br />        {<br />            prefix[i] = ++j;<br />        }<br />        else<br />        {<br />            j = 0;<br />            prefix[i] = j;<br />        }<br />        <br />        i++;<br />    }<br />    <br />    return prefix;           <br />}    </p>
		<p>//返回target串在pattern串中第一次匹配的index <br />int KMPStringMatch(char* strPattern, int iPatternLen, char* strTarget, int iTargetLen, int* prefix)<br />{<br />    int i = 0;<br />    int j = 0;<br />    <br />    while(i&lt;iPatternLen &amp;&amp; j&lt;iTargetLen)<br />    {<br />        if(j==0 || strPattern[i]==strTarget[j])<br />        {<br />            i++;  j++;<br />        }<br />        else<br />        {<br />            j = prefix[j];<br />        }<br />    }             <br />    <br />    free(prefix);<br />     <br />    if(j==iTargetLen)<br />    {<br />        return i-j;<br />    }<br />    else<br />    {<br />        return -1;<br />    }         <br />}         </p>
		<p>int KMP(char* strPattern, char* strTarget)<br />{<br />    int* prefix = GetPrefixValue(strPattern, strlen(strPattern)); <br />    int index = KMPStringMatch(strPattern, strlen(strPattern), strTarget, strlen(strTarget), prefix);<br />    return index; <br />}</p>
		<p>//在文本文件中查找target串出现的行数 <br />int SearchInTxtFile(char* fileName, char* strTarget)<br />{<br />    FILE* hFile = fopen(fileName, "r");<br />    <br />    char str[1024]; <br />    int count = 0; <br />    <br />    <br />    while(fgets(str, 1024, hFile)) <br />    { <br />        if(KMP(str, strTarget)!=-1)<br />        {<br />            count++; <br />        }    <br />    }      <br />    <br />    fclose(hFile);<br />    hFile=NULL;<br />    <br />    return count; <br />}     <br />             <br />int main()<br />{<br />    char ch;<br />    char str1[] = "abcabcabctasksb,abTo";<br />    char str2[] = "abc";<br />    <br />    double t=clock();<br />    printf("%d\n", KMP(str1,str2)); <br />    printf("耗时：%f毫秒！\n", (clock()-t));<br />    <br />    t=clock(); <br />    printf("find %d \n", SearchInTxtFile("c:\\txt.txt", "NULL"));<br />    printf("耗时：%f毫秒！\n", (clock()-t));<br />    scanf("%c", &amp;ch);</p>
		<p>    return 0;<br />} </p>
<img src ="http://www.cppblog.com/bourne/aggbug/9472.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bourne/" target="_blank">Bourne</a> 2006-07-05 23:48 <a href="http://www.cppblog.com/bourne/archive/2006/07/05/9472.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>c/c++中的时间函数</title><link>http://www.cppblog.com/bourne/archive/2006/07/05/9423.html</link><dc:creator>Bourne</dc:creator><author>Bourne</author><pubDate>Wed, 05 Jul 2006 04:12:00 GMT</pubDate><guid>http://www.cppblog.com/bourne/archive/2006/07/05/9423.html</guid><wfw:comment>http://www.cppblog.com/bourne/comments/9423.html</wfw:comment><comments>http://www.cppblog.com/bourne/archive/2006/07/05/9423.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/bourne/comments/commentRss/9423.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bourne/services/trackbacks/9423.html</trackback:ping><description><![CDATA[
		<font size="2">摘要：<br />本文从介绍基础概念入手，探讨了在C/C++中对日期和时间操作所用到的数据结构和函数，并对计时、时间的获取、时间的计算和显示格式等方面进行了阐述。本文还通过大量的实例向你展示了time.h头文件中声明的各种函数和数据结构的详细使用方法。<br /><br />关键字：UTC（世界标准时间），Calendar Time（日历时间），epoch（时间点），clock tick（时钟计时单元）<br /><br />1．概念<br />在C/C++中，对字符串的操作有很多值得注意的问题，同样，C/C++对时间的操作也有许多值得大家注意的地方。最近，在技术群中有很多网友也多次问到过C++语言中对时间的操作、获取和显示等等的问题。下面，在这篇文章中，笔者将主要介绍在C/C++中时间和日期的使用方法.<br /><br />通过学习许多C/C++库，你可以有很多操作、使用时间的方法。但在这之前你需要了解一些“时间”和“日期”的概念，主要有以下几个：<br /><br />Coordinated Universal Time（UTC）：协调世界时，又称为世界标准时间，也就是大家所熟知的格林威治标准时间（Greenwich Mean Time，GMT）。比如，中国内地的时间与UTC的时差为+8，也就是UTC+8。美国是UTC-5。<br /><br />Calendar Time：日历时间，是用“从一个标准时间点到此时的时间经过的秒数”来表示的时间。这个标准时间点对不同的编译器来说会有所不同，但对一个编译系统来说，这个标准时间点是不变的，该编译系统中的时间对应的日历时间都通过该标准时间点来衡量，所以可以说日历时间是“相对时间”，但是无论你在哪一个时区，在同一时刻对同一个标准时间点来说，日历时间都是一样的。<br /><br />epoch：时间点。时间点在标准C/C++中是一个整数，它用此时的时间和标准时间点相差的秒数（即日历时间）来表示。<br /><br />clock tick：时钟计时单元（而不把它叫做时钟滴答次数），一个时钟计时单元的时间长短是由CPU控制的。一个clock tick不是CPU的一个时钟周期，而是C/C++的一个基本计时单位。<br /><br />我们可以使用ANSI标准库中的time.h头文件。这个头文件中定义的时间和日期所使用的方法，无论是在结构定义，还是命名，都具有明显的C语言风格。下面，我将说明在C/C++中怎样使用日期的时间功能。<br /><br />2． 计时<br /><br />C/C++中的计时函数是clock()，而与其相关的数据类型是clock_t。在MSDN中，查得对clock函数定义如下：<br /><br />clock_t clock( void );<br /><br />这个函数返回从“开启这个程序进程”到“程序中调用clock()函数”时之间的CPU时钟计时单元（clock tick）数，在MSDN中称之为挂钟时间（wal-clock）。其中clock_t是用来保存时间的数据类型，在time.h文件中，我们可以找到对它的定义：<br /><br />#ifndef _CLOCK_T_DEFINED<br />typedef long clock_t;<br />#define _CLOCK_T_DEFINED<br />#endif<br /><br />很明显，clock_t是一个长整形数。在time.h文件中，还定义了一个常量CLOCKS_PER_SEC，它用来表示一秒钟会有多少个时钟计时单元，其定义如下：<br /><br />#define CLOCKS_PER_SEC ((clock_t)1000)<br /><br />可以看到每过千分之一秒（1毫秒），调用clock（）函数返回的值就加1。下面举个例子，你可以使用公式clock()/CLOCKS_PER_SEC来计算一个进程自身的运行时间：<br /><br />void elapsed_time()<br />{<br />printf("Elapsed time:%u secs.\n",clock()/CLOCKS_PER_SEC);<br />}<br /><br />当然，你也可以用clock函数来计算你的机器运行一个循环或者处理其它事件到底花了多少时间：<br /><br />#include “stdio.h”<br />#include “stdlib.h”<br />#include “time.h”<br /><br />int main( void )<br />{<br />   long    i = 10000000L;<br />   clock_t start, finish;<br />   double  duration;<br />   /* 测量一个事件持续的时间*/<br />   printf( "Time to do %ld empty loops is ", i );<br />   start = clock();<br />   while( i-- )      ;<br />   finish = clock();<br />   duration = (double)(finish - start) / CLOCKS_PER_SEC;<br />   printf( "%f seconds\n", duration );<br />   system("pause");<br />}<br /><br />在笔者的机器上，运行结果如下：<br /><br />Time to do 10000000 empty loops is 0.03000 seconds<br /><br />上面我们看到时钟计时单元的长度为1毫秒，那么计时的精度也为1毫秒，那么我们可不可以通过改变CLOCKS_PER_SEC的定义，通过把它定义的大一些，从而使计时精度更高呢？通过尝试，你会发现这样是不行的。在标准C/C++中，最小的计时单位是一毫秒。<br /><br />3．与日期和时间相关的数据结构<br /><br />在标准C/C++中，我们可通过tm结构来获得日期和时间，tm结构在time.h中的定义如下：<br /><br />#ifndef _TM_DEFINED<br />struct tm {<br />        int tm_sec;     /* 秒 – 取值区间为[0,59] */<br />        int tm_min;     /* 分 - 取值区间为[0,59] */<br />        int tm_hour;    /* 时 - 取值区间为[0,23] */<br />        int tm_mday;    /* 一个月中的日期 - 取值区间为[1,31] */<br />        int tm_mon;     /* 月份（从一月开始，0代表一月） - 取值区间为[0,11] */<br />        int tm_year;    /* 年份，其值等于实际年份减去1900 */<br />        int tm_wday;    /* 星期 – 取值区间为[0,6]，其中0代表星期天，1代表星期一，以此类推 */<br />        int tm_yday;    /* 从每年的1月1日开始的天数 – 取值区间为[0,365]，其中0代表1月1日，1代表1月2日，以此类推 */<br />        int tm_isdst;   /* 夏令时标识符，实行夏令时的时候，tm_isdst为正。不实行夏令时的进候，tm_isdst为0；不了解情况时，tm_isdst()为负。*/<br />        };<br />#define _TM_DEFINED<br />#endif<br /><br />ANSI C标准称使用tm结构的这种时间表示为分解时间(broken-down time)。<br /><br />而日历时间（Calendar Time）是通过time_t数据类型来表示的，用time_t表示的时间（日历时间）是从一个时间点（例如：1970年1月1日0时0分0秒）到此时的秒数。在time.h中，我们也可以看到time_t是一个长整型数：<br /><br />#ifndef _TIME_T_DEFINED<br />typedef long time_t;         /* 时间值 */<br />#define _TIME_T_DEFINED      /* 避免重复定义 time_t */<br />#endif<br /><br />大家可能会产生疑问：既然time_t实际上是长整型，到未来的某一天，从一个时间点（一般是1970年1月1日0时0分0秒）到那时的秒数（即日历时间）超出了长整形所能表示的数的范围怎么办？对time_t数据类型的值来说，它所表示的时间不能晚于2038年1月18日19时14分07秒。为了能够表示更久远的时间，一些编译器厂商引入了64位甚至更长的整形数来保存日历时间。比如微软在Visual C++中采用了__time64_t数据类型来保存日历时间，并通过_time64()函数来获得日历时间（而不是通过使用32位字的time()函数），这样就可以通过该数据类型保存3001年1月1日0时0分0秒（不包括该时间点）之前的时间。<br /><br />在time.h头文件中，我们还可以看到一些函数，它们都是以time_t为参数类型或返回值类型的函数：<br /><br />double difftime(time_t time1, time_t time0);<br />time_t mktime(struct tm * timeptr);<br />time_t time(time_t * timer);<br />char * asctime(const struct tm * timeptr);<br />char * ctime(const time_t *timer);<br /><br />此外，time.h还提供了两种不同的函数将日历时间（一个用time_t表示的整数）转换为我们平时看到的把年月日时分秒分开显示的时间格式tm：<br /><br />struct tm * gmtime(const time_t *timer);                                          <br />struct tm * localtime(const time_t * timer);<br /><br />通过查阅MSDN，我们可以知道Microsoft C/C++ 7.0中时间点的值（time_t对象的值）是从1899年12月31日0时0分0秒到该时间点所经过的秒数，而其它各种版本的Microsoft C/C++和所有不同版本的Visual C++都是计算的从1970年1月1日0时0分0秒到该时间点所经过的秒数。<br /><br />4．与日期和时间相关的函数及应用<br />在本节，我将向大家展示怎样利用time.h中声明的函数对时间进行操作。这些操作包括取当前时间、计算时间间隔、以不同的形式显示时间等内容。<br /><br />4.1 获得日历时间<br /><br />我们可以通过time()函数来获得日历时间（Calendar Time），其原型为：<br /><br />time_t time(time_t * timer);<br /><br />如果你已经声明了参数timer，你可以从参数timer返回现在的日历时间，同时也可以通过返回值返回现在的日历时间，即从一个时间点（例如：1970年1月1日0时0分0秒）到现在此时的秒数。如果参数为空（NUL），函数将只通过返回值返回现在的日历时间，比如下面这个例子用来显示当前的日历时间：<br /><br />#include "time.h"<br />#include "stdio.h"<br />int main(void)<br />{<br />struct tm *ptr;<br />time_t lt;<br />lt =time(NUL);<br />printf("The Calendar Time now is %d\n",lt);<br />return 0;<br />}<br /><br />运行的结果与当时的时间有关，我当时运行的结果是：<br /><br />The Calendar Time now is 1122707619<br /><br />其中1122707619就是我运行程序时的日历时间。即从1970年1月1日0时0分0秒到此时的秒数。<br /><br />4.2 获得日期和时间<br /><br />这里说的日期和时间就是我们平时所说的年、月、日、时、分、秒等信息。从第2节我们已经知道这些信息都保存在一个名为tm的结构体中，那么如何将一个日历时间保存为一个tm结构的对象呢？<br /><br />其中可以使用的函数是gmtime()和localtime()，这两个函数的原型为：<br /><br />struct tm * gmtime(const time_t *timer);                                          <br />struct tm * localtime(const time_t * timer);<br /><br />其中gmtime()函数是将日历时间转化为世界标准时间（即格林尼治时间），并返回一个tm结构体来保存这个时间，而localtime()函数是将日历时间转化为本地时间。比如现在用gmtime()函数获得的世界标准时间是2005年7月30日7点18分20秒，那么我用localtime()函数在中国地区获得的本地时间会比世界标准时间晚8个小时，即2005年7月30日15点18分20秒。下面是个例子：<br /><br />#include "time.h"<br />#include "stdio.h"<br />int main(void)<br />{<br />struct tm *local;<br />time_t t;<br />t=time(NUL);<br />local=localtime(&amp;t);<br />printf("Local hour is: %d\n",local-&gt;tm_hour);<br />local=gmtime(&amp;t);<br />printf("UTC hour is: %d\n",local-&gt;tm_hour);<br />return 0;<br />}<br /><br />运行结果是：<br /><br />Local hour is: 15<br />UTC hour is: 7<br /><br />4.3 固定的时间格式<br /><br />我们可以通过asctime()函数和ctime()函数将时间以固定的格式显示出来，两者的返回值都是char*型的字符串。返回的时间格式为：<br /><br />星期几 月份 日期 时:分:秒 年\n\0<br />例如：Wed Jan 02 02:03:55 1980\n\0<br /><br />其中\n是一个换行符，\0是一个空字符，表示字符串结束。下面是两个函数的原型：<br /><br />char * asctime(const struct tm * timeptr);<br />char * ctime(const time_t *timer);<br /><br />其中asctime()函数是通过tm结构来生成具有固定格式的保存时间信息的字符串，而ctime()是通过日历时间来生成时间字符串。这样的话，asctime（）函数只是把tm结构对象中的各个域填到时间字符串的相应位置就行了，而ctime（）函数需要先参照本地的时间设置，把日历时间转化为本地时间，然后再生成格式化后的字符串。在下面，如果t是一个非空的time_t变量的话，那么：<br /><br />printf(ctime(&amp;t));<br /><br />等价于：<br /><br />struct tm *ptr;<br />ptr=localtime(&amp;t);<br />printf(asctime(ptr));<br /><br />那么，下面这个程序的两条printf语句输出的结果就是不同的了（除非你将本地时区设为世界标准时间所在的时区）：<br /><br />#include "time.h"<br />#include "stdio.h"<br />int main(void)<br />{<br />struct tm *ptr;<br />time_t lt;<br />lt =time(NUL);<br />ptr=gmtime(&amp;lt);<br />printf(asctime(ptr));<br />printf(ctime(&amp;lt));<br />return 0;<br />}<br /><br />运行结果：<br /><br />Sat Jul 30 08:43:03 2005<br />Sat Jul 30 16:43:03 2005<br /><br />4.4 自定义时间格式<br /><br />我们可以使用strftime（）函数将时间格式化为我们想要的格式。它的原型如下：<br /><br />size_t strftime(<br />   char *strDest,<br />   size_t maxsize,<br />   const char *format,<br />   const struct tm *timeptr <br />);<br /><br />我们可以根据format指向字符串中格式命令把timeptr中保存的时间信息放在strDest指向的字符串中，最多向strDest中存放maxsize个字符。该函数返回向strDest指向的字符串中放置的字符数。<br /><br />函数strftime()的操作有些类似于sprintf()：识别以百分号(%)开始的格式命令集合，格式化输出结果放在一个字符串中。格式化命令说明串strDest中各种日期和时间信息的确切表示方法。格式串中的其他字符原样放进串中。格式命令列在下面，它们是区分大小写的。<br /><br />%a 星期几的简写 <br />%A 星期几的全称 <br />%b 月分的简写 <br />%B 月份的全称 <br />%c 标准的日期的时间串 <br />%C 年份的后两位数字 <br />%d 十进制表示的每月的第几天 <br />%D 月/天/年 <br />%e 在两字符域中，十进制表示的每月的第几天 <br />%F 年-月-日 <br />%g 年份的后两位数字，使用基于周的年 <br />%G 年分，使用基于周的年 <br />%h 简写的月份名 <br />%H 24小时制的小时 <br />%I 12小时制的小时<br />%j 十进制表示的每年的第几天 <br />%m 十进制表示的月份 <br />%M 十时制表示的分钟数 <br />%n 新行符 <br />%p 本地的AM或PM的等价显示 <br />%r 12小时的时间 <br />%R 显示小时和分钟：hh:mm <br />%S 十进制的秒数 <br />%t 水平制表符 <br />%T 显示时分秒：hh:mm:ss <br />%u 每周的第几天，星期一为第一天 （值从0到6，星期一为0）<br />%U 第年的第几周，把星期日做为第一天（值从0到53）<br />%V 每年的第几周，使用基于周的年 <br />%w 十进制表示的星期几（值从0到6，星期天为0）<br />%W 每年的第几周，把星期一做为第一天（值从0到53） <br />%x 标准的日期串 <br />%X 标准的时间串 <br />%y 不带世纪的十进制年份（值从0到99）<br />%Y 带世纪部分的十进制年份 <br />%z，%Z 时区名称，如果不能得到时区名称则返回空字符。<br />%% 百分号<br /><br />如果想显示现在是几点了，并以12小时制显示，就象下面这段程序：<br /><br />#include “time.h”<br />#include “stdio.h”<br />int main(void)<br />{<br />struct tm *ptr;<br />time_t lt;<br />char str[80];<br />lt=time(NUL);<br />ptr=localtime(&amp;lt);<br />strftime(str,100,"It is now %I %p",ptr);<br />printf(str);<br />return 0;<br />}<br /><br />其运行结果为：<br />It is now 4PM<br /><br />而下面的程序则显示当前的完整日期：<br /><br />#include &lt;stdio.h&gt;<br />#include &lt;time.h&gt;<br /><br />void main( void )<br />{<br />        struct tm *newtime;<br />        char tmpbuf[128];<br />        time_t lt1;<br />        time( &amp;lt1 );<br />        newtime=localtime(&amp;lt1);<br />        strftime( tmpbuf, 128, "Today is %A, day %d of %B in the year %Y.\n", newtime);<br />        printf(tmpbuf);<br />}<br /><br />运行结果：<br /><br />Today is Saturday, day 30 of July in the year 2005.<br /><br />4.5 计算持续时间的长度<br /><br />有时候在实际应用中要计算一个事件持续的时间长度，比如计算打字速度。在第1节计时部分中，我已经用clock函数举了一个例子。Clock()函数可以精确到毫秒级。同时，我们也可以使用difftime()函数，但它只能精确到秒。该函数的定义如下：<br /><br />double difftime(time_t time1, time_t time0);<br /><br />虽然该函数返回的以秒计算的时间间隔是double类型的，但这并不说明该时间具有同double一样的精确度，这是由它的参数觉得的（time_t是以秒为单位计算的）。比如下面一段程序：<br /><br />#include "time.h"<br />#include "stdio.h"<br />#include "stdlib.h"<br />int main(void)<br />{<br />time_t start,end;<br />start = time(NUL);<br />system("pause");<br />end = time(NUL);<br />printf("The pause used %f seconds.\n",difftime(end,start));//&lt;-<br />system("pause");<br />return 0;<br />}<br /><br />运行结果为：<br />请按任意键继续. . .<br />The pause used 2.000000 seconds.<br />请按任意键继续. . .<br /><br />可以想像，暂停的时间并不那么巧是整整2秒钟。其实，你将上面程序的带有“//&lt;-”注释的一行用下面的一行代码替换：<br /><br />printf("The pause used %f seconds.\n",end-start);<br /><br />其运行结果是一样的。<br /><br />4.6 分解时间转化为日历时间<br /><br />这里说的分解时间就是以年、月、日、时、分、秒等分量保存的时间结构，在C/C++中是tm结构。我们可以使用mktime（）函数将用tm结构表示的时间转化为日历时间。其函数原型如下：<br /><br />time_t mktime(struct tm * timeptr);<br /><br />其返回值就是转化后的日历时间。这样我们就可以先制定一个分解时间，然后对这个时间进行操作了，下面的例子可以计算出1997年7月1日是星期几：<br /><br />#include "time.h"<br />#include "stdio.h"<br />#include "stdlib.h"<br />int main(void)<br />{<br />struct tm t;<br />time_t t_of_day;<br />t.tm_year=1997-1900;<br />t.tm_mon=6;<br />t.tm_mday=1;<br />t.tm_hour=0;<br />t.tm_min=0;<br />t.tm_sec=1;<br />t.tm_isdst=0;<br />t_of_day=mktime(&amp;t);<br />printf(ctime(&amp;t_of_day));<br />return 0;<br />}<br /><br />运行结果：<br /><br />Tue Jul 01 00:00:01 1997<br /><br />现在注意了，有了mktime()函数，是不是我们可以操作现在之前的任何时间呢？你可以通过这种办法算出1945年8月15号是星期几吗？答案是否定的。因为这个时间在1970年1月1日之前，所以在大多数编译器中，这样的程序虽然可以编译通过，但运行时会异常终止。<br /><br />5．总结<br /><br />本文介绍了标准C/C++中的有关日期和时间的概念，并通过各种实例讲述了这些函数和数据结构的使用方法。笔者认为，和时间相关的一些概念是相当重要的，理解这些概念是理解各种时间格式的转换的基础，更是应用这些函数和数据结构的基础。<br /><br />参考文献<br /><br />[1] 标准C++程序设计教程，电子工业出版社，2003。<br />[2] MSDN Library， Microsoft Corporation，2003。</font>
<img src ="http://www.cppblog.com/bourne/aggbug/9423.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bourne/" target="_blank">Bourne</a> 2006-07-05 12:12 <a href="http://www.cppblog.com/bourne/archive/2006/07/05/9423.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转贴:链接错误LINK2001</title><link>http://www.cppblog.com/bourne/archive/2006/06/20/8756.html</link><dc:creator>Bourne</dc:creator><author>Bourne</author><pubDate>Tue, 20 Jun 2006 08:36:00 GMT</pubDate><guid>http://www.cppblog.com/bourne/archive/2006/06/20/8756.html</guid><wfw:comment>http://www.cppblog.com/bourne/comments/8756.html</wfw:comment><comments>http://www.cppblog.com/bourne/archive/2006/06/20/8756.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/bourne/comments/commentRss/8756.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bourne/services/trackbacks/8756.html</trackback:ping><description><![CDATA[
		<p>上网搜东西的时候搜到了这个，觉得蛮使用的，放在这里以备后用！<br /><br />--  LINK2001<br />学习VC＋＋时经常会遇到链接错误LNK2001，该错误非常讨厌，因为对于<br />编程者来说，最好改的错误莫过于编译错误，而一般说来发生连接错误时，<br />编译都已通过。产生连接错误的原因非常多，尤其LNK2001错误，常常使人不<br />明其所以然。如果不深入地学习和理解VC＋＋，要想改正连接错误LNK2001非<br />常困难。<br />　　初学者在学习VC＋＋的过程中，遇到的LNK2001错误的错误消息主要为：<br />　　unresolved external symbol “symbol”（不确定的外部“符号”）。<br />　　如果连接程序不能在所有的库和目标文件内找到所引用的函数、变量或<br />标签，将产生此错误消息。一般来说，发生错误的原因有两个：一是所引用<br />的函数、变量不存在、拼写不正确或者使用错误；其次可能使用了不同版本<br />的连接库。<br />　　以下是可能产生LNK2001错误的原因：<br />　　一．由于编码错误导致的LNK2001。<br />　　1．不相匹配的程序代码或模块定义（.DEF）文件能导致LNK2001。例如, <br />如果在C＋＋ 源文件内声明了一变量“var1”，却试图在另一文件内以变量<br />“VAR1”访问该变量,将发生该错误。<br />　　2．如果使用的内联函数是在.CPP文件内定义的，而不是在头文件内定<br />义将导致LNK2001错误。<br />　　3．调用函数时如果所用的参数类型同函数声明时的类型不符将会产生<br />LNK2001。<br />　　4．试图从基类的构造函数或析构函数中调用虚拟函数时将会导致LNK2001。<br />　　5．要注意函数和变量的可公用性，只有全局变量、函数是可公用的。<br />　　静态函数和静态变量具有相同的使用范围限制。当试图从文件外部访问<br />任何没有在该文件内声明的静态变量时将导致编译错误或LNK2001。<br />　　函数内声明的变量（局部变量） 只能在该函数的范围内使用。<br />　　C＋＋ 的全局常量只有静态连接性能。这不同于C，如果试图在C＋＋的<br />多个文件内使用全局变量也会产生LNK2001错误。一种解决的方法是需要时在<br />头文件中加入该常量的初始化代码，并在.CPP文件中包含该头文件；另一种<br />方法是使用时给该变量赋以常数。<br />　　二．由于编译和链接的设置而造成的LNK2001<br />　　1．如果编译时使用的是/NOD（/NODEFAULTLIB）选项，程序所需要的运行<br />库和MFC库在连接时由编译器写入目标文件模块， 但除非在文件中明确包含<br />这些库名，否则这些库不会被链接进工程文件。在这种情况下使用/NOD将导<br />致错误LNK2001。<br />　　2．如果没有为wWinMainCRTStartup设定程序入口，在使用Unicode和MFC<br />时将得到“unresolved external on _WinMain@16”的LNK2001错误信息。<br />　　3．使用/MD选项编译时,既然所有的运行库都被保留在动态链接库之内，<br />源文件中对“func”的引用，在目标文件里即对“__imp__func” 的引用。<br />如果试图使用静态库LIBC.LIB或LIBCMT.LIB进行连接，将在__imp__func上发<br />生LNK2001；如果不使用/MD选项编译，在使用MSVCxx.LIB连接时也会发生LNK2001。<br />　　4．使用/ML选项编译时，如用LIBCMT.LIB链接会在_errno上发生LNK2001。<br />　　5．当编译调试版的应用程序时，如果采用发行版模态库进行连接也会产<br />生LNK2001；同样，使用调试版模态库连接发行版应用程序时也会产生相同的<br />问题。<br />　　6．不同版本的库和编译器的混合使用也能产生问题，因为新版的库里可<br />能包含早先的版本没有的符号和说明。<br />　　7．在不同的模块使用内联和非内联的编译选项能够导致LNK2001。如果<br />创建C＋＋库时打开了函数内联（/Ob1或/Ob2），但是在描述该函数的相应头<br />文件里却关闭了函数内联（没有inline关键字），这时将得到该错误信息。<br />为避免该问题的发生，应该在相应的头文件中用inline关键字标志内联函数。<br />　　8．不正确的/SUBSYSTEM或/ENTRY设置也能导致LNK2001。<br />　　其实，产生LNK2001的原因还有很多，以上的原因只是一部分而已，对初<br />学者来说这些就够理解一阵子了。但是，分析错误原因的目的是为了避免错<br />误的发生。LNK2001错误虽然比较困难，但是只要注意到了上述问题，还是能<br />够避免和予以解决的。</p>
<img src ="http://www.cppblog.com/bourne/aggbug/8756.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bourne/" target="_blank">Bourne</a> 2006-06-20 16:36 <a href="http://www.cppblog.com/bourne/archive/2006/06/20/8756.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC++中的连接问题，请大侠帮忙，我快崩溃了</title><link>http://www.cppblog.com/bourne/archive/2006/06/19/8711.html</link><dc:creator>Bourne</dc:creator><author>Bourne</author><pubDate>Mon, 19 Jun 2006 08:56:00 GMT</pubDate><guid>http://www.cppblog.com/bourne/archive/2006/06/19/8711.html</guid><wfw:comment>http://www.cppblog.com/bourne/comments/8711.html</wfw:comment><comments>http://www.cppblog.com/bourne/archive/2006/06/19/8711.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/bourne/comments/commentRss/8711.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bourne/services/trackbacks/8711.html</trackback:ping><description><![CDATA[
		<p>还是我做的那个链表的模板类<br />我分别写了头文件Chain.h，源文件Chain.cpp,并且在main.cpp中进行测试。<br />但是在连接的时候出现了问题，不知道什么原因，希望能够有高手指点一下，非常感谢！<br /><br />其中Chain.h声明了类的数据成员和成员函数，具体内容如下：<br /><br /><font color="#0000ff" size="2">#ifndef _CHAIN_H<br />#define _CHAIN_H</font></p>
		<p>
				<font color="#0000ff" size="2">#include &lt;iostream&gt;<br />using namespace std;</font>
		</p>
		<p>
				<font color="#0000ff" size="2">template&lt;class T&gt;<br />class Chain;</font>
		</p>
		<p>
				<br />
				<font color="#0000ff" size="2">template&lt;class T&gt;<br />class ChainNode<br />{<br /> friend class Chain&lt;T&gt;;<br /> friend ostream&amp; operator&lt;&lt;(ostream&amp; out, const Chain&lt;T&gt;&amp; x);<br />private:<br /> T data;<br /> ChainNode&lt;T&gt; *link;<br />};</font>
		</p>
		<p>
				<font color="#0000ff" size="2">template&lt;class T&gt;<br />class Chain{</font>
		</p>
		<p>
				<font color="#0000ff" size="2">public:<br /> Chain(int p) {first = 0;};<br /> ~Chain();<br /> bool IsEmpty() const {return first == 0;}<br /> int Length() const;<br /> bool Find(int k, T&amp; x) const;<br /> int Search(const T&amp; x) const;<br /> //Chain&lt;T&gt;&amp; Delete(int k, T&amp; x);<br /> Chain&lt;T&gt;&amp; Insert(int k, const T&amp; x);<br /> void Output(ostream&amp; out = cout) const;<br />private:<br /> ChainNode&lt;T&gt; *first; // 指向第一个节点的指针<br />};</font>
		</p>
		<p>
				<font color="#0000ff" size="2">template&lt;class T&gt;<br />ostream&amp; operator&lt;&lt;(ostream&amp; out, const Chain&lt;T&gt;&amp; x);</font>
		</p>
		<p>
				<font color="#0000ff" size="2">#endif  // _CHAIN<br /><br /><font color="#000000" size="3">  在Chain.cpp中对Chain.h中声明的函数进行了定义，具体内容如下：<br /><br /><font color="#0000ff" size="2">#include "Chain.h"<br />#include &lt;iostream&gt;<br />using namespace std;</font></font></font>
		</p>
		<p>
				<font size="+0">
						<font color="#0000ff" size="2">template&lt;class T&gt;<br />Chain&lt;T&gt;::~Chain()<br />{<br /> //链表的析构函数,用于删除链表中的所有节点<br /> ChainNode&lt;T&gt; *ptr = first; <br /> while (ptr)<br /> {<br />  first = ptr-&gt;link;<br />  delete ptr;<br />  ptr = first;<br /> }<br />}</font>
				</font>
		</p>
		<p>
				<font size="+0">
						<font color="#0000ff" size="2">template&lt;class T&gt;<br />int Chain&lt;T&gt;::Length() const<br />{<br /> //返回链表中的元素总数<br /> int count = 0;<br /> ChainNode&lt;T&gt; *ptr = first;<br /> while (ptr)<br /> {<br />  ++count;<br />  ptr = ptr-&gt;link;<br /> }<br /> return count;<br />}</font>
				</font>
		</p>
		<p>
				<font size="+0">
						<font color="#0000ff" size="2">template&lt;class T&gt;<br />bool Chain&lt;T&gt;::Find(int k, T&amp; x) const<br />{<br /> //寻找链表中的第k个元素，并将其传送至x<br /> //如果不存在第k个元素，则返回false，否则返回true<br /> if (k &lt; 1)<br /> {<br />  return false;<br /> }<br /> int count = k;<br /> ChainNode&lt;T&gt; *ptr = first;<br /> while (count &amp;&amp; ptr)<br /> {<br />  --count;<br />  ptr = ptr-&gt;link<br /> }<br /> if (!ptr)<br /> {<br />  return false;<br /> }<br /> x = ptr-&gt;data;<br /> return true;<br />}</font>
				</font>
		</p>
		<p>
				<font size="+0">
						<font color="#0000ff" size="2">template&lt;class T&gt;<br />int Chain&lt;T&gt;::Search(const T&amp; x) const<br />{<br /> //寻找x，如果发现x，则返回x的地址<br /> //如果x不在链表中，则返回0<br /> int count = 1;<br /> ChainNode&lt;T&gt; *ptr = first;<br /> while(ptr &amp;&amp; (ptr-&gt;data!=x))<br /> {<br />  ++count;<br />  ptr = ptr-&gt;link;<br /> }<br /> if (ptr)<br /> {<br />  return count;<br /> }<br /> else<br /> {<br />  return 0;<br /> }<br />}</font>
				</font>
		</p>
		<p>
				<font size="+0">
						<font color="#0000ff" size="2">template&lt;class T&gt;<br />void Chain&lt;T&gt;::Output(ostream&amp; out = cout) const<br />{<br /> ChainNode&lt;T&gt; *ptr = first;<br /> while (ptr)<br /> {<br />  out&lt;&lt;ptr-&gt;data&lt;&lt;"  ";<br />  ptr = ptr-&gt;link;<br /> }<br />}</font>
				</font>
		</p>
		<p>
				<font size="+0">
						<font color="#0000ff" size="2">//重载&lt;&lt;运算符<br />template&lt;class T&gt;<br />ostream&amp; operator&lt;&lt;(ostream&amp; out, const Chain&lt;T&gt;&amp; x)<br />{<br /> x.Output(out);<br /> return out;<br />}</font>
				</font>
		</p>
		<p>
				<font size="+0">
						<font color="#0000ff" size="2">template&lt;class T&gt;<br />Chain&lt;T&gt;&amp; Chain&lt;T&gt;::Insert(int k, const T&amp; x)<br />{<br /> ChainNode&lt;T&gt; *ptr = first;<br /> int count = 0;<br /> while (ptr &amp;&amp; count &lt; k)<br /> {<br />  ++count;<br />  ptr = ptr-&gt;link;<br /> }<br /> if (!ptr)  //如果没到第k个节点<br /> {<br /> <br /> }<br /> else<br /> {<br />  //要插入的新节点<br />  ChainNode&lt;T&gt;* cn = new ChainNode&lt;T&gt;;<br />  cn-&gt;data = x;<br />  cn-&gt;link = 0;<br />  if (ptr-&gt;link==0)  //到达了链表的结尾<br />  {<br />   ptr-&gt;link = cn;<br />  }<br />  else  //没到达结尾<br />  {  <br />   cn-&gt;link = ptr-&gt;link;<br />   ptr-&gt;link = cn;<br />  }<br /> }<br /> return *this<br />}<br /><br /><font color="#000000" size="3"> 在main.cpp中进行测试，测试的内容很少，但是刚开始就进行不了了。main.cpp内容如下：<br /><br />#include "Chain.h"<br />using namespace std;</font></font>
				</font>
		</p>
		<p>
				<font size="+0">
						<font color="#0000ff" size="2">
								<font color="#000000" size="3">int main()<br />{<br /> Chain&lt;int&gt; c;<br /> cout&lt;&lt;c.Length();<br /> return 0;<br />}<br /><br />编译的时候没有问题，但是在连接的时候就出现了问题，报错如下：<br /><font color="#ff0000">--------------------Configuration: Chain - Win32 Debug--------------------<br />Linking...<br />main.obj : error LNK2001: unresolved external symbol "public: __thiscall Chain&lt;int&gt;::~Chain&lt;int&gt;(void)" (</font><a href="mailto:??1?$Chain@H@@QAE@XZ"><font color="#ff0000">??1?$Chain@H@@QAE@XZ</font></a><font color="#ff0000">)<br />main.obj : error LNK2001: unresolved external symbol "public: int __thiscall Chain&lt;int&gt;::Length(void)const " (</font><a href="mailto:?Length@?$Chain@H@@QBEHXZ"><font color="#ff0000">?Length@?$Chain@H@@QBEHXZ</font></a><font color="#ff0000">)<br />Debug/Chain.exe : fatal error LNK1120: 2 unresolved externals<br />Error executing link.exe.</font></font>
						</font>
				</font>
		</p>
		<p>
				<font size="+0">
						<font size="2">
								<font color="#ff0000" size="3">Chain.exe - 3 error(s), 0 warning(s)<br /><font color="#000000">但是从报错信息来看，应该是在main.cpp中没有找到所用到的函数 ~Chain&lt;int&gt;(void)和Length()的定义，在main.cpp中一共用到了三个函数，构造函数Chain()，但是构造函数是在Chain.h中定义的，所以编译器找到了其定义，但是另外两个函数是在Chain.cpp中定义的，而且目前报错没有找到，但是如果在main.cpp中引入#include "Chain.cpp"时，编译和连接就没有问题，这就证实了原来的估计是没有错的。我实在是不知道问题出现在哪里，所以希望哪位高手看出问题来的话，请告诉我，多谢了！</font></font>
						</font>
				</font>
		</p>
<img src ="http://www.cppblog.com/bourne/aggbug/8711.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bourne/" target="_blank">Bourne</a> 2006-06-19 16:56 <a href="http://www.cppblog.com/bourne/archive/2006/06/19/8711.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>微软VC++对友元类和模板的支持真的这么差吗？</title><link>http://www.cppblog.com/bourne/archive/2006/06/17/8678.html</link><dc:creator>Bourne</dc:creator><author>Bourne</author><pubDate>Sat, 17 Jun 2006 15:39:00 GMT</pubDate><guid>http://www.cppblog.com/bourne/archive/2006/06/17/8678.html</guid><wfw:comment>http://www.cppblog.com/bourne/comments/8678.html</wfw:comment><comments>http://www.cppblog.com/bourne/archive/2006/06/17/8678.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/bourne/comments/commentRss/8678.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/bourne/services/trackbacks/8678.html</trackback:ping><description><![CDATA[
		<p>以前写代码的时候就遇到VC++对友元支持得不太好的问题，同时也看过侯捷老师对gnu c++, VC++, BCB 三种编译器的比较，其中VC++对模板友元的支持就不是很好。<br />今天晚上写了一个比较简单的链表的模板类，其中头文件Chain.h原来的代码如下：<br /><br /><font color="#0000ff" size="2">#include &lt;iostream&gt;<br />using namespace std;</font></p>
		<p>
				<font color="#0000ff" size="2">#ifndef _CHAIN<br />#define _CHAIN</font>
		</p>
		<p>
				<font color="#0000ff" size="2">template&lt;class T&gt;<br />class ChainNode<br />{<br /> friend class Chain&lt;T&gt;;<br />private:<br /> T data;<br /> ChainNode&lt;T&gt; *link;<br />};</font>
		</p>
		<p>
				<font color="#0000ff" size="2">template&lt;class T&gt;<br />class Chain{<br />public:<br /> Chain() <br /> {<br />  first = 0;<br /> };<br /> ~Chain();<br /> bool IsEmpty() const {return first == 0;}<br /> int Length() const;<br /> bool Find(int k, T&amp; x) const;<br /> int Search(const T&amp; x) const;<br /> //Chain&lt;T&gt;&amp; Delete(int k, T&amp; x);<br /> Chain&lt;T&gt;&amp; Insert(int k, const T&amp; x);<br /> void Output(ostream&amp; out = cout) const;<br />private:<br /> ChainNode&lt;T&gt; *first; // 指向第一个节点的指针<br />};</font>
		</p>
		<p>
				<font color="#0000ff" size="2">#endif  // _CHAIN<br /><br />结果报错：<br />--------------------Configuration: Chain - Win32 Debug--------------------<br />Compiling...<br />Chain.cpp<br />g:\work plan\c++ code practice\chain\chain.h(17) : error C2059: syntax error : '&lt;'<br />        g:\work plan\c++ code practice\chain\chain.h(21) : see reference to class template instantiation 'ChainNode&lt;T&gt;' being compiled<br />g:\work plan\c++ code practice\chain\chain.h(17) : error C2238: unexpected token(s) preceding ';'<br />        g:\work plan\c++ code practice\chain\chain.h(21) : see reference to class template instantiation 'ChainNode&lt;T&gt;' being compiled<br />g:\work plan\c++ code practice\chain\chain.h(40) : error C2989: 'Chain' : template class has already been defined as a non-template class<br />        g:\work plan\c++ code practice\chain\chain.h(17) : see declaration of 'Chain'<br />g:\work plan\c++ code practice\chain\chain.cpp(6) : error C2059: syntax error : '&lt;'<br />g:\work plan\c++ code practice\chain\chain.cpp(6) : error C2588: '::~Chain' : illegal global destructor<br />g:\work plan\c++ code practice\chain\chain.cpp(6) : fatal error C1903: unable to recover from previous error(s); stopping compilation<br />Error executing cl.exe.</font>
		</p>
		<p>
				<font color="#0000ff" size="2">Chain.obj - 6 error(s), 0 warning(s)<br /><br /><font size="3"><font color="#000000">感觉从代码来看应该是没有问题的，如果哪个高手看出问题来了请一定告诉我啊，如果知道编译不通过的原因也请一定要告诉我啊。没办法，最后采用解决的办法就是修改ChainNode的定义了，定义为结构体:)<br /><font color="#0000ff" size="2">template&lt;class T&gt;<br />struct ChainNode<br />{<br />  T data;<br />  ChainNode&lt;T&gt; *link;<br />};</font><br />反正结构体中的数据成员都是public的，至于访问限制的实现就依靠迭代器来实现了，g++的STL中的树结点不也是结构体吗？:)<br /></font></font></font>
		</p>
<img src ="http://www.cppblog.com/bourne/aggbug/8678.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/bourne/" target="_blank">Bourne</a> 2006-06-17 23:39 <a href="http://www.cppblog.com/bourne/archive/2006/06/17/8678.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>