📄 intro.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN"><!-- This collection of hypertext pages is Copyright 1995-2004 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. --><html><!-- Mirrored from c-faq.com/book/intro.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 07:59:10 GMT --><head><meta name=GENERATOR content="faqproc"><title>Introduction</title></head><body bgcolor="#ffffff"><H1>Introduction</H1><p>You've probably had the experience,in a bar or at a party,of losing a bet on whether you could perform some seemingly simple task which turned out,based on idiosyncrasies of the human bodyor the laws of physics,to be impossible.The guy making the bet knew that the more people he challenged,the more likely he was to keep winning,because those idiosyncrasies and laws,even if obscure,are fairly constant and predictable.</p><p>In a similar way,if you take a large number of peopleand set them at some complex task,such aslearning the C programming language,many of them will run into exactly the same problemsand have exactly the same questions.The questions and problems may or may not have been predictablewhen the task was first designed,and the answers may seem obvious in hindsight,but people <em>will</em> keep havingsome ofthe same problems,and the same questions <em>will</em> keep coming up.These problems and questions don't necessarily indicatethat the task was impossible,but merely that it was difficult enough to be interesting.</p><p>Not surprisingly,these problems and questionsare regularly askedon the Internet,particularly in the interactive discussion newsgroupsknown as Usenet.Thereasonably obviousidea of collecting the frequent questions gave rise to a tradition ofFrequently Asked Questions or FAQ lists.FAQ lists don't always serve their intended purpose of reducing the incidence of frequently asked questions,but if the questions are in fact consistent,the fact that they were asked often enough to be selected for inclusion in an FAQ listsuggests that they might match questions which you or some other readers of this book are asking, too.</p><H3>About This Book</H3><p>Most books(about C or any other topic)are written from the author's point of view.They discuss the topics the author thinks you should know,presented in a way which makes sense to the author.If that way doesn't make sense toyou(and, at some level, it can't,because the author presumably knows the material alreadywhile you presumably don't),you may be left with deep, unanswered questions.</p><p>This book,however,is organized around some 400of thosequestions,allbased on realonesasked by real peopleattempting to learn or program in C.This book is nottargeted atjust thosetopics that the author thinks are important;it is targeted at the topics that real readers think are important,based on the questions they ask.The chances are good that if you are learning or using C,and you have a questionabout Cwhich isn't answered in any of the other books you've checked,you'll find it answered here.</p><p>This book can't promise toanswer <em>every</em> question you'll havewhen you're programming in C,sincemany of the questions that will come up in your programming will have to do with your problem domain,andthis bookcoversonly the C language itself.Just as it can't cover every aspect of every problemanyone might try to solve in C,this book cannot cover every aspect of every operating system which anyone might try to write a C program for,or every algorithm which anyone might try to implement in C.Specific problems, specific operating systems, and general-purpose algorithms are properly discussed in books or other materials devoted to those topics.Nevertheless,certainquestions involving operating systems and algorithmsarequite frequent,sochapters <a href="../osdep/index.html">19</a> and<a href="../misc/index.html">20</a>provide brief, introductory answers toa few of them,but please don't expect the treatment to be complete.</p><p>The questions in this book are those that people typically have after reading an introductory C textbookor taking a C programming class.Therefore,this book will <em>not</em> teach you C,nor does it discuss fundamental issues which any C textbook should cover.Furthermore,this book's answers are intendedfor the most partto be definitively correct,and to avoidpropagating any misconceptions.Therefore, a few answers are more elaboratethan might at first seem necessary:they give you the <em>complete</em> picture,rather than oversimplifying or leaving out important details.(It is, after all, oversimplifications or omitted detailswhich arebehind many of the misconceptions which this book's questions and answers address.)Within the elaborate answersyou will findshortcuts and simplifications where necessary,and in the Glossary beginning on page xxxyou will find definitions of the precise terms which accurate explanations often demand.The shortcuts and simplifications are of course safe ones:they should not lead to later misunderstandings,and you can always come back to the more complete explanations,or pursue some of the references,if you later desire the full story.</p><p>As we'll see particularly in chapters <a href="../expr/index.html">3</a>and<a href="../ansi/index.html">11</a>,the standard definitions of C do not specifythe behavior ofevery C program which can be written.Someprograms fall into various gray areas:they may happen to work on some systems,and they may not be strictly illegal,but they are not guaranteed to workeverywhere.This book is aboutportableC programming,so its answers advise against using nonportable constructsif at all possible.</p><p>The on-line FAQ listbehind this bookwaswritten as a dialog:when people didn't understand it, they said so.That feedback has been invaluable in refining the form of the answers.Though a printed book is obviously more static,such adialog is still appropriate:your comments, criticisms and suggestionsare welcome.If youhave access to the Internet,you may send comments to <TT>scs@aw.com</TT>,or you may send themon paper in care of the publisher.A list of any errors which are discovered in this bookwill be maintained and available on the Internet;see <a href="../misc/faqavail.html">question 20.40</a> for information.</p><H3>Question Format</H3><p>The bulk of this book consists of a series of question/answer pairs.Many answersalso contain references and notes.The notes, where they appear,are on the order of footnotes;you can skip them if you find that they're too picky.Several respected references are cited repeatedly,underthese abbreviations:<UL><li>ANSIThe (original) ANSI C Standard, X3.159-1989<li>CT&P<I>C Traps and Pitfalls</I>, by Andrew Koenig<li>H&SHarbison and Steele,<I>C: A Reference Manual</I>,Fourth Edition<li>ISOThe ISO C Standard, ISO 9899:1990<li>K&R1Kernighan and Ritchie,<I>The C Programming Language</I>,First Edition<li>K&R2Kernighan and Ritchie,<I>The C Programming Language</I>,Second Edition<li>PCS<I>Portable C Software</I>, by Mark Horton<li>RationaleThe Rationale for the ANSI C Standard, X3.159-1989</UL>Other references are cited by their full titles;full citations for all references appear in the Bibliography on page xxx.</p><p>This <TT>constant width</TT> typeface is used to indicate C syntax(function and variable names, keywords, etc.),and also to indicate a few operating system commands(<TT>cc</TT>, etc.).An occasional notation of the form tty(4) indicates the section ``tty'' in chapter 4 of the Unix Programmer's manual.</p><H3>Code Samples</H3><p>This is a book about C,somany small piecesof it are necessarily written in C.The examplesarewritten primarily for clarity of exposition.They are <em>not</em>always written in the most efficient waypossible;making them ``faster''would often make them less clear.(See <a href="../misc/efficiency.html">question 20.13</a>for more information about code efficiency.)They are primarilywritten using modern, ANSI-style syntax;see <a href="../ansi/preansi.html">question 11.29</a> for conversion tipsif you're still using a ``Classic'' compiler.</p><p>The author and publisherinvite you to use and modify these code fragments in your own programs,but of course we would appreciateacknowledgmentif you do so.(Some fragments are from other sources,and are so attributed;please acknowledge those contributors if you use those codes.)The source codefor the larger examples
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -