C : The Complete Reference, 4th Edition

2y ago
23 Views
2 Downloads
2.99 MB
1.1K Pages
Last View : 25d ago
Last Download : 3m ago
Upload by : Alexia Money
Transcription

C :The Complete Reference,Fourth Edition

About the AuthorHerbert Schildt is the world’s leading programmingauthor. He is an authority on the C, C , Java, and C#languages, and is a master Windows programmer. Hisprogramming books have sold more than 3 millioncopies worldwide and have been translated into allmajor foreign languages. He is the author of numerousbestsellers, including C : The Complete Reference, C#:The Complete Reference, Java 2: The Complete Reference,C: The Complete Reference, C from the Ground Up,C : A Beginner’s Guide, C#: A Beginner’s Guide, andJava 2: A Beginner’s Guide. Schildt holds a master’sdegree in computer science from the University ofIllinois. He can be reached at his consulting office at(217) 586-4683.Copyright 2003 by The McGraw-Hill Companies. Click here for terms of use.

C :The Complete Reference,Fourth EditionHerbert SchildtMcGraw-Hill/OsborneNew York Chicago San FranciscoLisbon London Madrid Mexico CityMilan New Delhi San JuanSeoul Singapore Sydney Toronto

Copyright 2003 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 anymeans, or stored in a database or retrieval system, without the prior written permission of the publisher.0-07-150239-4The material in this eBook also appears in the print version of this title: 0-07-222680-3.All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarkedname, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of thetrademark. 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 corporatetraining programs. For more information, please contact George Hoare, Special Sales, at george hoare@mcgraw-hill.com or(212) 904-4069.TERMS OF USEThis 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 onecopy 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 thework for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may beterminated 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 TOTHE 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 warrantor 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, inthe work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed throughthe 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/0072226803

ProfessionalWant to learn more?We hope you enjoy thisMcGraw-Hill eBook! Ifyou’d like more information about this book,its author, or related books and websites,please click here.

Contents at a GlancePart I The Foundation of C : The C Subset12345678910Part II1112An Overview of C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Arrays and Null-Terminated Strings . . . . . . . . . . . . . . . .Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Structures, Unions, Enumerations,and User-Defined Types . . . . . . . . . . . . . . . . . . . . . . . .C-Style Console I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .File I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Preprocessor and Comments . . . . . . . . . . . . . . . . . .3135789113137161187211237C An Overview of C . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Classes and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .v255289

viC : The Complete Reference131415161718192021222324Arrays, Pointers, References, and the DynamicAllocation Operators . . . . . . . . . . . . . . . . . . . . . . . . . . .Function Overloading, Copy Constructors,and Default Arguments . . . . . . . . . . . . . . . . . . . . . . . . .Operator Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . .Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Virtual Functions and Polymorphism . . . . . . . . . . . . . . .Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The C I/O System Basics . . . . . . . . . . . . . . . . . . . . . . .C File I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Run-Time Type ID and the Casting Operators . . . . . . .Namespaces, Conversion Functions,and Other Advanced Topics . . . . . . . . . . . . . . . . . . . . .Introducing the Standard Template Library . . . . . . . . . .325359383417443459487509539567591629Part III The Standard Function Library25262728293031The C-Based I/O Functions . . . . . . . . . . . . . . . . . . . . . . .The String and Character Functions . . . . . . . . . . . . . . . .The Mathematical Functions . . . . . . . . . . . . . . . . . . . . . .Time, Date, and Localization Functions . . . . . . . . . . . . .The Dynamic Allocation Functions . . . . . . . . . . . . . . . . .Utility Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Wide-Character Functions . . . . . . . . . . . . . . . . . . . . .699723737747757761775Part IV The Standard C Class Library32333435363738The Standard C I/O Classes . . . . . . . . . . . . . . . . . . . .The STL Container Classes . . . . . . . . . . . . . . . . . . . . . . . .The STL Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .STL Iterators, Allocators, and Function Objects . . . . . .The String Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Numeric Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Exception Handling and Miscellaneous Classes . . . . . .787811839861881897925

Contents at a GlancePart V3940ABApplying C Integrating New Classes: A Custom String Class . . . . . 935Parsing Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 963The .NET Managed Extensions to C . . . . . . . . . . . . . . 999C and the Robotics Age . . . . . . . . . . . . . . . . . . . . . . . . 1005Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1009vii

This page intentionally left blank

For more information about this title, click hereContentsIntroduction.xxixPart IThe Foundation of C : The C Subset12An Overview of C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3The Origins and History of C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .C Is a Middle-Level Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .C Is a Structured Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .C Is a Programmer’s Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Form of a C Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Library and Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Separate Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Understanding the .C and .CPP File Extensions . . . . . . . . . . . . . . . .45689101212Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13The Five Basic Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Modifying the Basic Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Identifier Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Where Variables Are Declared . . . . . . . . . . . . . . . . . . . . . . . .Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141516171818ix

xC : The Complete Reference3Formal Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The const and volatile Qualifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . .const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .volatile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Storage Class Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .extern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .static Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .register Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Variable Initializations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Hexadecimal and Octal Constants . . . . . . . . . . . . . . . . . . . .String Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Backslash Character Constants . . . . . . . . . . . . . . . . . . . . . . .Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Assignment Operator . . . . . . . . . . . . . . . . . . . . . . . . . . .Type Conversion in Assignments . . . . . . . . . . . . . . . . . . . . .Multiple Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Increment and Decrement . . . . . . . . . . . . . . . . . . . . . . . . . . .Relational and Logical Operators . . . . . . . . . . . . . . . . . . . . .Bitwise Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The ? Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The & and * Pointer Operators . . . . . . . . . . . . . . . . . . . . . . .The Compile-Time Operator sizeof . . . . . . . . . . . . . . . . . . .The Comma Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Dot (.) and Arrow ( ) Operators . . . . . . . . . . . . . . . . .The [ ] and ( ) Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Precedence Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Order of Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Type Conversion in Expressions . . . . . . . . . . . . . . . . . . . . . .Casts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Spacing and Parentheses . . . . . . . . . . . . . . . . . . . . . . . . . . . .Compound Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . 050515152525253545556Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57True and False in C and C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Selection Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Nested ifs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The if-else-if Ladder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The ? Alternative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Conditional Expression . . . . . . . . . . . . . . . . . . . . . . . . . .58595960626366

Contents45switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Nested switch Statements . . . . . . . . . . . . . . . . . . . . . . . . . . .Iteration Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The for Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .for Loop Variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Infinite Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .for Loops with No Bodies . . . . . . . . . . . . . . . . . . . . . . . . . . .The while Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The do-while Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Declaring Variables Within Selection and Iteration Statements . . .Jump Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The return Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The goto Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The break Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The exit( ) Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The continue Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Expression Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Block Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .677070707276777779818282838385868888Arrays and Null-Terminated Strings . . . . . . . . . . . . . . . .89Single-Dimension Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Generating a Pointer to an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . .Passing Single-Dimension Arrays to Functions . . . . . . . . . . . . . . . .Null-Terminated Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Two-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Arrays of Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Multidimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Indexing Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Array Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Unsized Array Initializations . . . . . . . . . . . . . . . . . . . . . . . . .A Tic-Tac-Toe Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9092929496100101102105106108Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113What Are Pointers? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Pointer Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Pointer Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Pointer Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Pointer Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Pointer Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Pointer Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Pointers and Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Arrays of Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Multiple Indirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Initializing Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Pointers to Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114115115116117117119121122123125126xi

xiiC : The Complete Reference678C's Dynamic Allocation Functions . . . . . . . . . . . . . . . . . . . . . . . . . . .Problems with Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129131Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137The General Form of a Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Scope Rules of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Function Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Call by Value, Call by Reference . . . . . . . . . . . . . . . . . . . . . .Creating a Call by Reference . . . . . . . . . . . . . . . . . . . . . . . . .Calling Functions with Arrays . . . . . . . . . . . . . . . . . . . . . . .argc and argv—Arguments to main( ) . . . . . . . . . . . . . . . . . . . . . . . .The return Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Returning from a Function . . . . . . . . . . . . . . . . . . . . . . . . . . .Returning Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Returning Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Functions of Type void . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .What Does main( ) Return? . . . . . . . . . . . . . . . . . . . . . . . . . .Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Function Prototypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Standard Library Function Prototypes . . . . . . . . . . . . . . . . .Declaring Variable-Length Parameter Lists . . . . . . . . . . . . . . . . . . . .Old-Style Versus Modern FunctionParameter Declarations . . . . . 58158Structures, Unions, Enumerations,and User-Defined Types . . . . . . . . . . . . . . . . . . . . . . . . .161Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Accessing Structure Members . . . . . . . . . . . . . . . . . . . . . . . .Structure Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Arrays of Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Passing Structures to Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Passing Structure Members to Functions . . . . . . . . . . . . . . .Passing Entire Structures to Functions . . . . . . . . . . . . . . . . .Structure Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Declaring a Structure Pointer . . . . . . . . . . . . . . . . . . . . . . . . .Using Structure Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Arrays and Structures Within Structures . . . . . . . . . . . . . . . . . . . . . .Bit-Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Using sizeof to Ensure Portability . . . . . . . . . . . . . . . . . . . . . . . . . . . .typedef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -Style Console I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .187An Important Application Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . .188

Contents9Reading and Writing Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A Problem with getchar( ) . . . . . . . . . . . . . . . . . . . . . . . . . . .Alternatives to getchar( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . .Reading and Writing Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Formatted Console I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .printf( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Printing Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Printing Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Displaying an Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The %n Specifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Format Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Minimum Field Width Specifier . . . . . . . . . . . . . . . . . .The Precision Specifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Justifying Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Handling Other Data Types . . . . . . . . . . . . . . . . . . . . . . . . . .The * and # Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .scanf( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Format Specifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Inputting Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Inputting Unsigned Integers . . . . . . . . . . . . . . . . . . . . . . . . .Reading Individual Characters Using scanf( ) . . . . . . . . . .Reading Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Inputting an Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The %n Specifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Using a Scanset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Discarding Unwanted White Space . . . . . . . . . . . . . . . . . . .Non-White-Space Characters in the Control String . . . . . .You Must Pass scanf( ) Addresses . . . . . . . . . . . . . . . . . . . . .Format Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Suppressing Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 03203203205205205206206206207208208208209File I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211C Versus C File I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Streams and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Text Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Binary Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .File System Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The File Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Opening a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Closing a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Writing a Character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Reading a Character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .212212212213213213214215215217217218xiii

xivC : The Complete Reference10Using fopen( ), getc( ), putc( ), and fclose( ) . . . . . . . . . . . . .Using feof( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Working with Strings: fputs( ) and fgets( ) . . . . . . . . . . . . . .rewind( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ferror( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Erasing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Flushing a Stream . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .fread( ) and fwrite( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Using fread( ) and fwrite( ) . . . . . . . . . . . . . . . . . . . . . . . . . . .fseek( ) and Random-Access I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . .fprintf( ) and fscanf( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Standard Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The Console I/O Connection . . . . . . . . . . . . . . . . . . . . . . . . .Using freopen( ) to Redirect the Standard Streams . . . . . .218220222223224226226227227229230232233234The Preprocessor and Comments . . . . . . . . . . . . . . . . . .237The Preprocessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .#define . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Defining Function-like Macros . . . . . . . . . . . . . . . . . . . . . . .#error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .#include . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Conditional Compilation Directives . . . . . . . . . . . . . . . . . . . . . . . . . .#if, #else, #elif, and #endif . . . . . . . . . . . . . . . . . . . . . . . . . . .#ifdef and #ifndef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .#undef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Using defined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .#line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .#pragma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The # and ## Preprocessor Operators . . . . . . . . . . . . . . . . . . . . . . . . .Predefined Macro Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Single-Line Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . art IIC 11An Overview of C . . . . . . . . . . . . . . . . . . . . . . . . . . . . .255The Origins of C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .What Is Object-Oriented Programming? . . . . . . . . . . . . . . . . . . . . . .Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Some C Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .A Sample C Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256257258258259259260

Contents1213A Closer Look at the I/O Operators . . . . . . . . . . . . . . . . . . .Declaring Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . .No Default to int . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The bool Data Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Old-Style vs. Modern C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The New C Headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Working with an Old Compiler . . . . . . . . . . . . . . . . . . . . . . .Introducing C Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Function Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Operator Overloading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Constructors and Destructors . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Complete Reference, C#: The Complete Reference, Java 2: The Complete Reference, C: The Complete Reference, C from the Ground Up, C : A Beginner’s Guide, C#: A Beginner’s Guide, and. Java 2: A Beginner’s Guide. Schildt holds a master’s degree in computer science from the University of Illinois. He can be reached at his consulting .

Related Documents:

May 02, 2018 · D. Program Evaluation ͟The organization has provided a description of the framework for how each program will be evaluated. The framework should include all the elements below: ͟The evaluation methods are cost-effective for the organization ͟Quantitative and qualitative data is being collected (at Basics tier, data collection must have begun)

Silat is a combative art of self-defense and survival rooted from Matay archipelago. It was traced at thé early of Langkasuka Kingdom (2nd century CE) till thé reign of Melaka (Malaysia) Sultanate era (13th century). Silat has now evolved to become part of social culture and tradition with thé appearance of a fine physical and spiritual .

On an exceptional basis, Member States may request UNESCO to provide thé candidates with access to thé platform so they can complète thé form by themselves. Thèse requests must be addressed to esd rize unesco. or by 15 A ril 2021 UNESCO will provide thé nomineewith accessto thé platform via their émail address.

̶The leading indicator of employee engagement is based on the quality of the relationship between employee and supervisor Empower your managers! ̶Help them understand the impact on the organization ̶Share important changes, plan options, tasks, and deadlines ̶Provide key messages and talking points ̶Prepare them to answer employee questions

Dr. Sunita Bharatwal** Dr. Pawan Garga*** Abstract Customer satisfaction is derived from thè functionalities and values, a product or Service can provide. The current study aims to segregate thè dimensions of ordine Service quality and gather insights on its impact on web shopping. The trends of purchases have

Chính Văn.- Còn đức Thế tôn thì tuệ giác cực kỳ trong sạch 8: hiện hành bất nhị 9, đạt đến vô tướng 10, đứng vào chỗ đứng của các đức Thế tôn 11, thể hiện tính bình đẳng của các Ngài, đến chỗ không còn chướng ngại 12, giáo pháp không thể khuynh đảo, tâm thức không bị cản trở, cái được

Le genou de Lucy. Odile Jacob. 1999. Coppens Y. Pré-textes. L’homme préhistorique en morceaux. Eds Odile Jacob. 2011. Costentin J., Delaveau P. Café, thé, chocolat, les bons effets sur le cerveau et pour le corps. Editions Odile Jacob. 2010. Crawford M., Marsh D. The driving force : food in human evolution and the future.

Le genou de Lucy. Odile Jacob. 1999. Coppens Y. Pré-textes. L’homme préhistorique en morceaux. Eds Odile Jacob. 2011. Costentin J., Delaveau P. Café, thé, chocolat, les bons effets sur le cerveau et pour le corps. Editions Odile Jacob. 2010. 3 Crawford M., Marsh D. The driving force : food in human evolution and the future.