📄 colonequal.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN"><!-- This collection of hypertext pages is Copyright 1995-2005 by Steve Summit. --><!-- Content from the book "C Programming FAQs: Frequently Asked Questions" --><!-- (Addison-Wesley, 1995, ISBN 0-201-84519-9) is made available here by --><!-- permission of the author and the publisher as a service to the community. --><!-- It is intended to complement the use of the published text --><!-- and is protected by international copyright laws. --><!-- The on-line content may be accessed freely for personal use --><!-- but may not be published or retransmitted without explicit permission. --><!-- --><!-- this page built Sat Dec 24 21:47:47 2005 by faqproc version 2.7 --><!-- from source file misclang.sgml dated Wed Dec 21 13:02:49 2005 --><!-- corresponding to FAQ list version 4.0 --><html><!-- Mirrored from c-faq.com/misc/colonequal.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 07:59:05 GMT --><head><meta name=GENERATOR content="faqproc"><title>Question 20.22</title><link href="quintplus.html" rev=precedes><link href="with.html" rel=precedes><link href="index.html" rev=subdocument></head><body bgcolor="#ffffff"><a href="quintplus.html" rev=precedes><img src="../images/buttonleft.gif" alt="prev"></a><a href="index.html" rev=subdocument><img src="../images/buttonup.gif" alt="up"></a><a href="with.html" rel=precedes><img src="../images/buttonright.gif" alt="next"></a> <a href="../index-2.html"><img src="../images/buttontop.gif" alt="top/contents"></a><a href="../search.html"><img src="../images/buttonsrch.gif" alt="search"></a><hr><p><!-- qbegin --><h1>comp.lang.c FAQ list<font color=blue>·</font><!-- qtag -->Question 20.22</h1><p><font face=Helvetica size=8 color=blue><b>Q:</b></font>If the assignment operator were <TT>:=</TT>,wouldn't it then be harder to accidentally write things like<TT>if(a = b)</TT> ?</p><p><hr><p><font face=Helvetica size=8 color=blue><b>A:</b></font>Yes, but it would also bejust alittle bitmore cumbersometo type all of the assignment statementswhich a typical program contains.</p><p>In any case,it's really too late to be worrying about this sort of thing now.The choices of <TT>=</TT> for assignment and <TT>==</TT> for comparisonwere made,rightly or wrongly,over two decades ago,and are not likely to be changed.(With respect to the question,many compilers and versions of <TT>lint</TT>will warn about <TT>if(a = b)</TT>and similar expressions;see also question <a href="../style/revtest.html">17.4</a>.)</p><p>As a point of historical interest,the choices were made based on the observation that assignmentis more frequent than comparison,and so deserves fewer keystrokes.In fact,using <TT>=</TT> for assignment inC and its predecessor Brepresented a change fromB's own predecessorBCPL,which did use <TT>:=</TT>as its assignment operator.(See also question <a href="nameofc.html">20.38</a>).</p><!-- aend --><p><hr><a href="quintplus.html" rev=precedes><img src="../images/buttonleft.gif" alt="prev"></a><a href="index.html" rev=subdocument><img src="../images/buttonup.gif" alt="up"></a><a href="with.html" rel=precedes><img src="../images/buttonright.gif" alt="next"></a> <a href="../questions.html"><img src="../images/buttontop.gif" alt="contents"></a><a href="../search.html"><img src="../images/buttonsrch.gif" alt="search"></a><br><!-- lastfooter --><a href="../about.html">about this FAQ list</a> <a href="../eskimo.html">about eskimo</a> <a href="../search.html">search</a> <a href="../feedback.html">feedback</a> <a href="copyright.html">copyright</a><p>Hosted by<a href="http://www.eskimo.com/"><img src="../../www.eskimo.com/img/link/eskitiny.gif" alt="Eskimo North"></a></body><!-- Mirrored from c-faq.com/misc/colonequal.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 07:59:05 GMT --></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -