ebook img

C: the complete reference PDF

859 Pages·2000·5.53 MB·english
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview C: the complete reference

Page i C The Complete Reference Fourth Edition Page ii ABOUT THE AUTHOR Herbert Schildt is the world's leading programming author. He is an authority on the C and C++ languages, a master Windows programmer, and an expert on Java. His programming books have sold more that 2.5 million copies worldwide and have been translated into all major foreign languages. He is the author of numerous bestsellers, including C++: The Complete Reference, Teach Yourself C, Teach Yourself C++, C++ from the Ground Up, Windows 2000 Programming from the Ground Up, and Java: The Complete Reference. Schildt holds a master's degree in computer science from the University of Illinois. He can be reached at his consulting office at (217) 586-4683. Page iii C The Complete Reference Fourth Edition Herbert Schildt Page iv Copyright © 2000 by The McGraw-Hill Companies. All rights reserved. Manufactured in the United States of America. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher. 0-07-213295-7 The material in this eBook also appears in the print version of this title: 0-07-212124-6. All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps. McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. For more information, please contact George Hoare, Special Sales, at [email protected] or (212) 904-4069. TERMS OF USE This is a copyrighted work and The McGraw-Hill Companies, Inc. (''McGraw-Hill") and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill's prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms. THE WORK IS PROVIDED "AS IS". McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw- Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise. DOI: 10.1036/0-07-213295-7 Page v CONTENTS Preface xxiii Part I Foundational C 1 3 An Overview of C A Brief History of C 4 C Is a Middle-Level Language 5 C Is a Structured Language 6 C Is a Programmer's Language 8 Compilers Vs. Interpreters 9 The Form of a C Program 10 The Library and Linking 11 Separate Compilation 12 Compiling a C Program 13 C's Memory Map 13 C Vs. C++ 14 Review of Terms 15 Page vi 2 17 Expressions The Basic Data Types 18 Modifying the Basic Types 18 Identifier Names 20 Variables 21 Where Variables Are Declared 21 Local Variables 22 Formal Parameters 25 Global Variables 26 The Four C Scopes 27 Type Qualifiers 28 const 28 volatile 30 Storage Class Specifiers 30 extern 31 static Variables 33 register Variables 35 Variable Initializations 36 Constants 37 Hexadecimal and Octal Constants 38 String Constants 38 Backslash Character Constants 39 Operators 40 The Assignment Operator 40 Arithmetic Operators 43 The Increment and Decrement Operators 44 Relational and Logical Operators 46 Bitwise Operators 48 The ? Operator 53 The & and * Pointer Operators 53 The Compile-Time Operator sizeof 55 The Comma Operator 56 The Dot (.) and Arrow (–>) Operators 56 The [ ] and ( ) Operators 57 Precedence Summary 58 Expressions 58 Order of Evaluation 58 Type Conversion in Expressions 59 Casts 60 Spacing and Parentheses 61 3 63 Statements True and False in C 64 Page vii Selection Statements 64 if 64 Nested ifs 66 The if-else-if Ladder 67 The ? Alternative 69 The Conditional Expression 72 switch 72 Nested switch Statements 75 Iteration Statements 76 The for Loop 76 for Loop Variations 77 The Infinite Loop 82 for Loops with No Bodies 82 Declaring Variables within a for Loop 83 The while Loop 83 The do-while Loop 86 Jump Statements 87 The return Statement 87 The goto Statement 88 The break Statement 89 The exit( ) Function 90 The continue Statement 91 Expression Statements 93 Block Statements 93 4 95 Arrays and Strings Single-Dimension Arrays 96 Generating a Pointer to an Array 97 Passing Single-Dimension Arrays to Functions 98 Strings 99 Two-Dimensional Arrays 101 Arrays of Strings 106 Multidimensional Arrays 107 Indexing Pointers 108 Array Initialization 110 Unsized Array Initializations 112 Variable-Length Arrays 113 A Tic-Tac-Toe Example 114 5 119 Pointers What Are Pointers? 120 Pointer Variables 121 The Pointer Operators 121

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.