2008-06-25

余音绕梁:比尔-盖茨经典语录

  作为微软创始人兼董事会主席,比尔·盖茨的一言一行自然颇受关注,然而,多年来一些被认为是盖茨名言的表述其实并非出自这位电脑天才之口。以“640K内存对于任何人来说都足够了”这句话为例,据说这是盖茨在1981年的话,旨在说明IBM PC内存达到640K这一重大突破。还有一句强安在盖茨头上的“名言”是,“倘若通用汽车公司技术革新的速度能赶上电脑业,我们早就开上每加仑油跑1000英里、售价只有25美元的汽车了。”
  1996年,盖茨在接受媒体采访时澄清了有关“640K内存”的传闻:“我虽说过一些蠢话,做过一些傻事,可这句话绝对不是我说的。业界从没有人说某种容量的内存已经足够了的话。但竟然有人将640K内存已经足够这样无聊的话安在我的头上,经常有人问起我这件事。”
  “我从来没说过这样的话;但它却像谣传一样到处传播,以讹传讹。你知道IBM PC内存只有640K的时候,业界所经历的痛苦吗?它们的内存一度只有512K,我们还不断推动PC内存向更大的容量发展。我从来没有说过这番言论,倒是说过与之相反的话。”
  《PC世界》杂志搜遍了微软官方网站、IDG通讯社档案库以及网上的其他正规采访来源,搜集了不少真正出自盖茨之口的名言。在看过这些发言和访谈后,你一定会认为盖茨绝对是一个梦想家,一个具有敏锐观察力和渊博知识的智者。

“如果我只想赢的话,我早就跑到另外一个舞台上了。如果我以前为自己设定了终线,难道你不认为我几年前就已冲线了吗?”


——1994年接受《花花公子》杂志的采访

“我们总是高估今后一两年内将要发生的变革,总是低估未来10年将要发生的变革。所以,不要让你自己陷入无所作为的窘境。”

——盖茨的著作《前方之路》,1996年出版

“我希望自己有机会编写更多代码。我确实是在管闲事。他们不许把我编写的代码放入即将发布的软件产品中。过去8年他们一直在这样做。而我说将加入他们行列,利用周末编写代码时,他们显得很诧异,确实不再像以往那样相信我的编程能力了。”

——1997年9月26日,在圣迭戈发表的演讲
“请记住,我没有美元,有的只是微软的股票。因此,只有通过乘法运算,你才能把我的财富转变为一些令人恐怖的数字。”

——1994年,接受《花花公子》杂志的采访
“我希望自己不是全球首富,这没有任何好处。”

——2006年,在西雅图市的演讲
“我不得不说,在搜索引擎上成为弱者其实很有意思,我们已为此组建了规模庞大的开发团队,我肯定自己会为此记住所付出的努力。”

——2008年5月21日,在微软华盛顿州雷德蒙总部advance 08大会上的发言

“公平地说,今天发生的一切就像是印刷机、电话和无线电时代的来临。这些通讯工具确实具有深入人心的影响。它们让这个世界变得更小了,使得科学研究效率更高,使得政治家能以全新的方式工作。它们虽对人们的教育方式影响有限,但人们对他们将发生的巨大变化充满乐观。现在,实现联网的个人电脑的功能在诸多方面远远比上述其他通讯设备更强大。”

——1996年5月29日,在马萨诸塞州剑桥市哈佛互联网协会大会上的发言
“PC和互联网将成为生活必需品,目前还没能够达到这一点,但我们肯定我们正处于实现这一目标的轨道上,届时,它们将像汽车一样普遍。”

——1998年6月25日,在旧金山Windows 98操作系统发布会上的发言
“大家知道,很多人希望把他们积累的财富留给下一代,这样做当然合情合理,无可厚非。但对我个人而言,如果我能把自己有幸掌管的巨额财富回馈社会,用到重要的事业上,如科技、教育、医学研究、社会服务及其他领域,这更利于社会,也更利于我的孩子。”

——1998年3月4日,接受PBS电视台王牌主持人查理·罗斯(Charlie Rose)的采访

“我坚信,任何有助于改善交流的工具,对人们相互学习以及他们达到自己感兴趣的自由度都具有深远的影响。在俄罗斯,电子邮件是使人们和谐相处和思考的重要工具,所以,他们会希望重新回到以前的政府管理模式吗?在世界任何一个角落,你会发现拥有这些工具的地方,人们的生活确实有着令人难以置信的差异。我最初开始考虑从事慈善事业的时候,我回顾并研究了历史上一些基金会的运作方式,分析了何种事情能让人们生活大不相同,何种事情能产生非常显著的影响。我最早关注的一个方面是人口增长问题,我要保证一些家庭获得重要信息,帮他们在打算要几个孩子的问题上作出准确决策,目标是分析人口增长在低于预期的时候,这样的结果对教育资源、环境资源、生活质量各个方面的后续影响。”

——2000年10月18日,在西雅图“数码鸿沟会议”上的发言

“在我们以美妙的方式教育每个孩子前,在每座城市的市中心得到彻底清理前,我们还没到无事可做的时候。”

——1994年,接受《花花公子》杂志的采访

“昨天,我的一个很不错的竞争对手斯科特·麦克尼里在这里谈起铃声市场,也就是数字铃声。大家总是说,微软试图涉足所有领域。因此我认为,说明这一点非常重要:微软公司不会涉足这个市场。”

——1998年1月10日,在拉斯维加斯举办的消费电子产品展上

“围绕着这次午宴,整个PC业已经聚在一起。比起以前我们使用的操作系统,Windows XP是最强大,最快,最可靠的操作系统。我们在这个新产品的开发上已投入几十亿美元。我们根据微软用户反馈的信息和电脑业的发展新方向研发出Windows XP。新的安全保护系统十分重要。隐私控制也很重要。实时信息连接是它的基础。”

——2001年10月25日,在纽约市举办的Windows XP促销活动上

“无论新技术在何时出现,父母都会对它的使用投以关注目光,这当然是一种合理的做法。在新技术名单中,互联网注定要排在最前面。你们都知道,我最大的孩子也不过11岁,因此,我们还没有陷入所谓的最为可怕的境地,你们知道我指的是孩子痴迷Facebook和把大量时间用于接发即时信息上。但我相信,这种事情正在前面等着我们。因此,我们决定对家里的电脑实施开放政策。这样一来,孩子们在使用电脑的时候就会意识到一点,我们会在不经意间出现在他们身旁。通过这种方式,我们不用做出大量限制,比如规定时间或者只能做一些特定的事情。我们一家人都会参与其中,看看这个世界正在发生什么并进行讨论。”

——2008年3月12日,在华盛顿特区美国众议院科学与技术委员会会议上

“在我上中学的时候,电脑还是一个令人敬畏的东西。人们使用穿孔卡片进入邮箱,将U形钉插进电脑让这种邪恶的机器陷入瘫痪,因为它们经常向你发送似乎并不准确的帐单。当时,还没有一个人将电脑视为一种授权工具。”

——2004年2月24日,在伊利诺伊大学厄巴纳香槟分校发表讲话

“如果一定要说什么东西让我感觉最棒,那就是这场软件革命及其带来的结果。现在,电脑的触角已经延伸到世界各个角落,无论是学校还是医院都在使用电脑,它们已经成为人们实现信息共享的必备工具。”

——2002年4月25日,在加利福尼亚州帕洛阿图市的斯坦福大学发表讲话

“30年前保罗·艾伦与我创建微软的时候,我对软件开发充满很多梦想。我们希望自己的软件能够对这个世界产生重要影响,让每一个办公桌和家庭拥有电脑也一直是我们讨论的话题。令我们感到惊讶和兴奋的是,梦想中的很多东西都已经成为现实并且涉及到生活的很多方面。我从没想过一家令人难于置信且异常重要的公司竟然源于这些最初的想法。”

——2006年6月15日,在华盛顿雷蒙德举行的记者招待会上,盖茨宣布,计划将慈善事业作为自己的“全职”,而将微软的工作作为“兼职”。
-----------------------------
以下英文原文来自pcworld.com
The Quotable Bill Gates
Nancy Weil, IDG News Service
Some of the most oft-repeated comments attributed to Bill Gates through the years were not uttered by Bill Gates. Take for instance "640K ought to be enough for anybody," which he supposedly said in 1981 to note that the 640K bytes of memory in IBM's PC was a significant breakthrough. Or his alleged comment that if General Motors "had kept up with technology like the computer industry has, we would all be driving [US]$25 cars that got 1,000 miles per gallon."
The latter is listed at the snopes.com Web site as an urban legend, and Gates has addressed the 640K quote in interviews. "I've said some stupid things and some wrong things, but not that. No one involved in computers would ever say that a certain amount of memory is enough for all time ... I keep bumping into that silly quotation attributed to me that says 640K of memory is enough. There's never a citation; the quotation just floats like a rumor, repeated again and again," he told Bloomberg Business News in 1996. "Do you realize the pain the industry went through while the IBM PC was limited to 640K? The machine was going to be 512K at one point, and we kept pushing it up. I never said that statement -- I said the opposite of that."
To assemble comments Gates actually did make over the years, we poured through the extensive speech archive at the Microsoft Web site, as well as the IDG News Service story archives and other interview sources available on the Internet. Reading over speeches and old interviews provided a reminder that Gates is a visionary, a smart man, with a range of knowledge about a lot of subjects.
-- "If I were a guy who just wanted to win, I would have already moved on to another arena. If I'd had some set idea of a finish line, don't you think I would have crossed it years ago?" Playboy magazine interview, 1994.
-- "We always overestimate the change that will occur in the next two years and underestimate the change that will occur in the next ten. Don't let yourself be lulled into inaction." From his book, "The Road Ahead," published in 1996.
-- "I wish I got a chance to write more code. I do mess around. They don't let my code go in shipping products. They haven't done that for about eight years now. And when I say I'm going to come in and write this over the weekend, they don't really believe me quite as much as they used to." Sept. 26, 1997, speaking in San Diego.
-- "Well, remember, I don't own dollars. I own Microsoft stock. So it's only through multiplication that you convert what I own into some scary number." Playboy interview, 1994.
-- "I wish I wasn't [the world's richest man]. There is nothing good that comes out of that." 2006, speaking in Seattle.
-- "I have to say, it's kind of fun to be the underdog (when it comes to search) ... We've done more on this to build a great team then on any effort I can remember," he said. -- at advance08, the Future of Media, May 21, 2008, Redmond, Washington.
-- "And so it's fair to say what's going on today is like the arrival of the printing press, or the telephone or the radio. And these communications tools did have pervasive effects. They made the world a smaller place. They allowed science to be done more efficiently. They allowed politics to be done a new way. They had a modest impact on how people were educated, but people were optimistic that they would make a very big change. Now, the personal computer connected to the Internet is far more powerful in many ways than any of these other communications devices." Harvard Conference on Internet Society, May 29, 1996, Cambridge, Massachusetts.
-- "The PC and the Internet are going to be fundamental. They're not there yet, but we're certainly on a course to do that, and it will be just like the automobile." Windows '98 launch, June 25, 1998, San Francisco.
-- "You know, in many people's cases, they decide they want to pass most of their wealth on to their children, and that's a perfectly legitimate choice. In my case, I think it's better for society and better for my children if the vast bulk of the wealth that I'm lucky enough to be shepherding at this point, if that goes back to causes that are important, things like access to technology, education, medical research, social services and a variety of things." Interview with Charlie Rose, March 4, 1998.
-- "Well, one of the privileges of success in this country is government scrutiny, and that's okay. I mean, we have a very sexy industry. If you worked at the Department of Justice, which would you rather investigate -- bread or software? ... Our, I guess you could call it, 'dispute' with the Department of Justice is about over whether we need to cripple our products or not. That is, can we take a feature that was once available separate from the operating system, like a browser or a graphical interface or any of the other things we've done, and then integrate that into the operating system so that users don't have to go out and buy those separate pieces and they have one unified product that creates a simple user interface ... So with Windows 98, we're not changing anything we do there. Worst case, they'll ask us to create a crippled product as well as the normal product, and that would be too bad. That would really hold us back, so we're quite confident that won't happen. -- Stanford University, Palo Alto, California, Jan. 27, 1998.
-- "I'm a great believer that any tool that enhances communication has profound effects in terms of how people can learn from each other, and how they can achieve the kind of freedoms that they're interested in. E-mail in Russia was very key in allowing people to get together and think about, did they want to revert back to the previous mode of government? In country after country, you can see that having these tools, there has really made a pretty incredible difference. ...
"When I first started thinking about philanthropy, I looked back and studied what some of the foundations had done over history, and looked at what kind of things could really make a difference, what kind of things could have a very dramatic impact. And one of the first causes I got attracted to was the issue of population growth, making sure that families had the information to decide exactly how many children they want to have, and with the goal there that if population growth is lower than it would be otherwise, the follow-on effect of that in terms of being able to have resources for education, for the environment, for every element of quality of life that you can imagine, that that would be a fundamentally advantageous thing." Digital Dividends Conference, Seattle, Oct. 18, 2000.
-- "So partly the reason the U.S. has the leadership we have today is that about 20 years ago, we had a high degree of humility. That is, we looked at Japan and sort of said, 'Wow, is their model superior, is there something about our model that could be strong.' And all these great things benefited from that approach. If during this period we don't retain at least some of that humility and look at what other countries are doing and learn from them, then our relative dominance will shrink faster than it should." Digital Dividends Conference, Seattle, Oct. 18, 2000.
-- "Until we're educating every kid in a fantastic way, until every inner city is cleaned up, there is no shortage of things to do." 1994 Playboy interview.
-- "Yesterday, one of my fine competitors, Scott McNealy, was here talking about the ring market, digital rings. And everybody always says Microsoft is trying to do everything. So I think it's important to state that this is one market that Microsoft will not be involved in." Consumer Electronics Show, Las Vegas, Jan. 10, 1998.
-- "The whole PC industry has come together around this launch. Windows XP is the most powerful, fastest, most reliable operating system we have ever done. We've poured literally billions of dollars of development into this new product. That was based on the feedback we had from our users, based on a vision of new activities that the PC could enable. The new security is very important. The privacy control is important. The messaging for real-time connections is a foundation. The new personal digital experiences; really we'll look back and say it's common sense, these are the ways that people deal with information. Together with Office XP, Windows XP will set a new standard for business." Windows XP Launch, Oct. 25, 2001, New York City.
-- "We are living in a phenomenal age. If we can spend the early decades of the 21st century finding approaches that meet the needs of the poor in ways that generate profits and recognition for business, we will have found a sustainable way to reduce poverty in the world. The task is open-ended. It will never be finished. But a passionate effort to answer this challenge will help change the world. I'm excited to be part of it." World Economic Forum, Jan. 24, 2008, Davos, Switzerland.
-- "Whenever new technologies come along, parents have a legitimate concern about how it's being used. And the Internet had to be high on the list there. You know, my oldest is 11, so we haven't quite gotten into the toughest years in terms of, you know, having Facebook accounts and spending a massive amount of time instant messaging. But I'm sure that's ahead. And we tended to keep our computers at home out in the open, so that as the kids are doing things on the computer, they know we're going to be walking by at any point. And by doing it that way, we've avoided having to have much in the way of hard limits, either in terms of time or specific things. We're just all involved in seeing what's going on and talking about what those things are." Remarks to the Committee on Science and Technology, U.S. House of Representatives, March 12, 2008, Washington, D.C.
-- "Certainly when I was in high school the computer was a very daunting thing, people talked about taking those punch cards you get in the mail and putting staples in them so you could defeat that evil machine that was always sending you bills that didn't seem to be correct. And nobody thought of it as a tool of empowerment." University of Illinois Urbana-Champaign, Feb. 24, 2004.
-- "If I had to say what is the thing that I feel best about, it's being involved in this whole software revolution and what comes out of that, because you can go all over the world and go into schools and see these computers being used and go into hospitals and see them being used, and see how they're tools for sharing information that hopefully leads to more peaceful conditions, and just the great research advances that come out of that." Stanford University, April 25, 2002, Palo Alto, California.
-- "When Paul Allen and I started Microsoft over 30 years ago, we had big dreams about software. We had dreams about the impact it could have. We talked about a computer on every desk and in every home. It's been amazing to see so much of that dream become a reality and touch so many lives. I never imagined what an incredible and important company would spring from those original ideas." News conference announcing plans for full-time philanthropy work and part-time Microsoft work, June 15, 2006, Redmond, Washington.
------------------------------------------------------------------
I like this:"We're just all involved in seeing what's going on and talking about what those things are"
In fact, there should not any other who can represent the initial age of the IT more suitable than Bill.
His career represent almost the entire development process of the modern IT industry.
In a word I still believe he is a deep thinker and have foresight!

2008-06-24

Linux下玩游戏

  其实linux下的游戏貌似有很多,而且其中甚至不乏虚幻或雷神之锤这种大作原生支持,不过个人不好fps类游戏,所以我们还是来玩玩经典的游戏吧。。

  既然如此本篇就只介绍模拟器了。。。。

SFC:
snes9X当仁不让是最强之作,而且也是开源的,你可以到www.snes9x.com那里去下载,linux的最新提供到1.43版,我本来希望自己编译的,可惜下了源代码编译的时候会出错误。。。无语,只能直接下官方提供的二进制版本了。
玩的时候最简单的方法直接 ./snes9x rom_direct就可以了。。

MD:
gens也是最强之作,同样也是开源作品,可以到:
http://sourceforge.net/project/showfiles.php?group_id=73619
下载最新版本。

PS:
epsxe当然也是最强之作,可以到http://www.epsxe.com/处下载最新版本,有linux的包。
运行的时候需要gtk1.2所以要安装一下
sudo apt-get install libgtk1.2 libgtk1.2-common
另外,玩的时候需要几个插件,网上搜到可以用的下载地址:
http://www.pbernert.com/gpupetexgl208.tar.gz 这个是Pete's XGL2 Driver 2.8
http://www.pbernert.com/gpupeopssoftx117.tar.gz 这个是P.E.Op.S. softX Driver 1.17
http://www.pbernert.com/spupeopsoss109.tar.gz 这个是P.E.Op.S. OSS Audio Driver 1.9
至于BIOS等直接上网搜吧。。。。

PS2:
PCSX2貌似是目前唯一的,可以到http://www.pcsx2.net/downloads.php去下载源码,自己编译,编译完成后默认会有一些插件的,BIOS自己找。。。

2008-06-22

Ubuntu下安装ATI催化剂驱动(Ubuntu 8.04&催化剂8.6)

  其实现在的ATI驱动已经是一个图形安装界面了,不过很可惜的是貌似直接安装的话,在Ubuntu下仍让没用,比如我的Ubuntu8.04,装好后进Gnome就一片白色。稍微参考了一些资料终于装成功了,解决了困扰我很久的桌面上有小图形碎片的问题。。。。而且播放视频也不会有一条一条的横线了。。。

下面看看我的过程:

先下载好驱动,ati-driver-installer-8-6-x86.x86_64.run
安装编译所需的包:

sudo apt-get update
sudo apt-get install module-assistant build-essential fakeroot dh-make debhelper debconf libstdc++5 linux-headers-generic dkms -y


删除fglrx:
sudo apt-get remove --purge fglrx-control
sudo apt-get remove --purge fglrx-kernel-source
sudo apt-get remove xorg-driver-fglrx
生成deb包:
sudo bash ati-driver-installer-8-6-x86.x86_64.run --buildpkg Ubuntu/hardy
运行完会得到四个包:
fglrx-amdcccle_8.501-0ubuntu1_i386.deb
fglrx-kernel-source_8.501-0ubuntu1_i386.deb
xorg-driver-fglrx_8.501-0ubuntu1_i386.deb
xorg-driver-fglrx-dev_8.501-0ubuntu1_i386.deb
将旧的fglrx模块从受限模块中列入黑名单
sudo gedit /etc/default/linux-restricted-modules-common
  把其中的DISABLED_MODULES=""改成DISABLED_MODULES="fglrx"

移除旧的fglrx包:

sudo rm /usr/src/fglrx-kernel*.deb


安装刚才获得的四个包:
dpkg -i ...
装好以后重启到recovery mode选root,之后:
sudo aticonfig --initial
sudo aticonfig --overlay-type=Xv
exit
然后选RESUME正常启动到系统
据说可能会不正常,不过我是正常了。。。
貌似之后不要修改受限驱动管理器里面的东西,否则会出问题。。

装好后查查看有没有成功启用:
glxinfo |grep -e 'direct' -e 'OpenGL'
我的机子上的显示结果是:

direct rendering: Yes
OpenGL vendor string: ATI Technologies Inc.
OpenGL renderer string: ATI Radeon X1200 Series
OpenGL version string: 2.1.7659 Release
OpenGL extensions:
可以测试一下看看:
glxgears

fgl_glxgears
我的集成显卡功能不强,第一个只有1000多帧,第二个只有300帧左右。。。


参考文章:http://forum.ubuntu.org.cn/viewtopic.php?t=119945

2008-06-17

悲惨的转片过程

  近日得到某位老兄转的一些MV,好不容易下载回来后欣喜之余发现这位老兄实在强悍,不知用何种方法转的片,视频是.264的音频是vobris还是什么的ogg的.还内嵌了字幕封装成mkv。。
  话说平日转mkv也从来没有遇到过问题,不过这位仁兄的片神奇的很,愣是不管加harddup还是noskip都要给我跳了不少帧,最后转出来的片毫无疑问是短了不少(确实是不少,基本差15%的时间)。用了mencoder和一些软件都一样的问题。。。无语至极。。。不过本人对动画的爱是无止境的。。。在这种欲望的驱使下,义无返顾的迈向了转片的过程。。。
  首先,从原来试的情况猜可能是封装的问题,所以先把东西分离吧。用MKVextractGUI(要先装MKVtoolnix)把原来的那个mkv里面的音频流、视频流、字幕流都分离出来。
  得到track1.h264,track2.ogg,track3.ssa,第一个是视频流,先用mencoder转换了吧。oac选copy就可以了。
  获得了Xvid编码的视频流后
  之后用VirtualDub打开分离了的音频和视频,都选上直接复制视频流,之后再在视频→帧速里面的帧速变化里选择更改以使视频和音频的持续时间相匹配。
  选择另存为avi就可以得到一个和正常的MV一样时间的文件了,接下来是字幕。
mencoder "F:\Video\OTHER\ft\test2.avi" -o "F:\Video\OTHER\ft\test3.avi" -oac mp3lame -lameopts vbr=0:br=64 -ovc xvid -xvidencopts fixed_quant=3:me_quality=6:cartoon -vf scale=320:-3,expand=0:-18:0:0:1 -ofps 20 -sub "F:\Video\OTHER\ft\track3.ssa" -font "F:\Video\OTHER\tt\msyh.ttf" -subfont-autoscale 1 -subfont-outline 2 -subpos 93 -spualign 2 -subcp utf-8
老东西了,可以搜索一下本站,前面的文章有介绍。记得因为我在windows下,所以必须加一个utf-8,否则mencoder转换出来的ssa字幕乱码。。。好像也可以直接用-utf8,我沒试就是。。。
  总之到这里就解决问题了。
  

  等等,还没结束,如果是idx和SUB的字幕的话我再windows下试的mencoder是不能加载的,方法只有用刚才下的mkvmerge吧前面得到的文件和字幕再打包成mkv,然后用mencoder转换,就用sid 0参数就ok了。。。

2008-06-15

C中的字符串处理

C的标准库中提供了大量的字符串处理函数,我们先从功能分类来看看它们:

字符串长度:
原型:
size_t strlen(char const *string);
size_t是在stddef.h中定义的无符号整型。

不受限制的字符串函数:
 即之经过最后的\0来判断字符串长度
 原型:
 复制字符串:
 char *strcpy(char *dst,char const *src);
 从src处将字符串复制到dst中,返回dst的一份拷贝,即指向dst指向的内存空间的指针
 连接字符串:
 char *strcat(char *dst,char const *src);
 注意dst原先需要包含一个字符串,可以是空串,返回dst的一份拷贝,即指向dst指向的内存空间的指针
 字符串比较:
 int strcmp(char const *s1,char const *s2);
 逐字符比较,第一个不匹配的字符中较小的那个所在的字符串被认为较小,若一个字符串是另一个的子字符串则认为前者较小。
 若第一个参数小于第二个,返回一个小于零的值,相等则返回零。


长度受限的字符串函数:
 char *strncpy(char *dst,char const *src,size_t len);
 char *strncat(char *dst,char const *src,size_t len);
 int strncmp(char const *s1,char const *s2,size_t len);

 strncpy只向dst写入len个字符,若src长度小于len就用\0填满。strncat向dst中复制len个字符加一个\0,

字符串查找:

 char *strchr(char const *str,int ch);
 char *strrchr(char const *str,int ch);
 strchr在str中查找ch第一次出现的位置,而后返回指向该位置的指针。如果没有找到则返回NULL执政,strrchr返回str中ch最后出现的位置。

 char *strpbrk(char const *str,char const *group);
 strpbrk在str中查找group中任何一个字符在str中第一个出现的位置,返回指向该位置的指针。
 char *strstr(char const *s1,char const *s2);
 在s1中查找整个s2出现的位置,并方会指向该位置的指针,若s2并没有完整的出现在s1中就返回一个NULL指针,若s2为空则返回s1。

高级字符串查找:
size_t strspn(char const *str,char const *group);
 size_t strcspn(char const *str,char const *group);
 strspn返回str中起始部分中包含group中任何字符的个数,注意是从str的第一个位置开始计数,知道发现第一个不属于group中的字符位置。
 strcspn正好相反,返回的是str中起始部分不包含在group中的任何字符的个数。
 如
int len1,len2;
char test[]="12895424,1238539,3.5399sfdsfdsf";
 
len1=strspn(test,"123456789");
len2=strcspn(test,"456789");

 len1的值是8,len2的值是2。

分段提取字符串:
有时候需要从一个字符串中提取一些由各种可能的符号分割的参数,这个时候就要用strtok了
char *strtok(char *str,char const *sep);
spe定义了分隔字符的集合,str指定被分隔的字符串,每次运行strtok时都会找到str中下一个分隔标记,并且保存在标记的位置,并用\0结尾被分割的前面部分,并返回前面被分割的那个部分的起始位置的指针,如果str是一个NULL指针,这strtok从前面被保存的位置开始继续查找,直到不再有标记时返回NULL。下面这个例子可以看看:

#include <stdio.h&rt;

#include<string.h&rt;

int main()
{
char spee[]=" \t\f\r\v";
char strf[]="tesr dfidjf tesfi .df",*rest;

for(rest=strtok(strf,spee);rest!=NULL;rest=strtok(NULL,spee))
{
printf("next token is %s \n",rest);
}
}

运行结果是

next token is tesr
next token is dfidjf
next token is tesfi
next token is .df

以上就是字符串的操作了,接下来是字符操作:

字符分类:
用于分辨是否是某种字符:包括下面这些函数,全部都是形如:int isupper(int ch);

函数
若符合以下条件则返回真 
iscntrl 任何控制字符
isspace 任何空白字符' ','\f','\n','\r','\t','\v'
isdigit
十进制0-9
isxdigit
十六进制数0-9,a-f,A-F
islower
小写字母
isupper
大写字母
isalpha
字母
isalnum
字幕或数字
ispunct
标点符号,以及不属于字母或数字的图信字符
isgraph任何图形字符
isprint
任何可打印字符

字幕转换:
int tolower(int ch);
int toupper(int ch);


内存操作:
如果要处理一些非字符串数据的时候可以使用,情况于字符串处理类似,所以放在一起。

void *memcpy(void *dst,void const *srt,size_t length);
void *memmove(void *dst,void const *srt,size_t length);
void *memcmp(void const *a,void const *b,size_t length);
void *memchr(void const *a,int ch,size_t length);
void *memset(void *a,int ch,size_t length);

length表示要处理的字节数,memcpy从src复制lenght个字节到dst,不允许dst和src有重叠,memmove和memcpy类似,只是允许dst和src重叠。
memchr从a的其实位置查找ch第一次出现的位置并返回指向该位置的指针,
memset用ch覆盖a的前length个长度。

2008-06-11

不同编程语言和操作系统对应的薪水

  The Unix Geek网站日前根据Indeed职位搜索引擎统计出了美国不同程序员的收入情况,按照他们使用的编程语言、操作系统和应用程序接口进行分类。下面是使用18种编程语言的程序员年薪情况:
Erlang: $99,000O
bjective-C: $82,000
Pascal: $81,000
C++: $80,000
TCL: $80,000
C#: $79,000
Java: $79,000
Python: $78,000
Perl: $77,000
Ruby: $74,000
COBOL: $73,000
JavaScript: $72,000
ColdFusion: $64,000
Delphi: $64,000
PHP: $64,000
Visual Basic: $64,000
C: $60,000
Haskell: $53,000
下面是按照4类操作系统划分:
GNU/Linux: $86,000
Solaris: $80,000
Microsoft Windows: $55,000
Mac OS X: $51,000

最后是按照应用程序接口划分:

Win32: $86,000
Tcl/Tk: $81,000
Qt: $76,000
GTK+: $75,000
.NET: $71,000 ($75,000 "Visual Studio")
Cocoa: $43,000 ($60,000 "Mac Programming")

2008-06-02

传说中的140字小说。

Recently,there's a Twitter Writing Contest,It required competeters can only write a novel by only 140 characters,Now let's see if these novel are funny.

First Place:

“Time travel works!” the note read. “However you can only travel to the past and one-way.” I recognized my own handwriting and felt a chill.

Second Place:

Tony was a snitch, so I wasn’t surprised when his torso turned up in the river. What did surprise me, though, was where they found his head.

Third Place

When Gibson hit that homerun in the fall of eighty-eight, my old man had never been so happy. He hugged me for the first time. I was eleven.