1. Trang chủ
  2. » Công Nghệ Thông Tin

Peter d hipson - advanced c

801 166 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Đây là quyển sách tiếng anh về lĩnh vực công nghệ thông tin cho sinh viên và những ai có đam mê. Quyển sách này trình về lý thuyết ,phương pháp lập trình cho ngôn ngữ C và C++.

Introduction i C C C C C C C C C C Advanced C Advanced C ii Introduction iii C C C C C C C C C C C C C C C C C C C Advanced C Peter D. Hipson A Division of Prentice Hall Computer Publishing 201 W. 103rd St., Indianapolis, Indiana 46290 USA Advanced C iv © 1992 by Sams Publishing All rights reserved. Printed in the United States of America. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system, without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Sams Publishing, 201 W. 103rd St., Indianapolis, IN 46290 International Standard Book Number: 0-672-30168-7 Library of Congress Catalog Card Number: 92-061304 96 95 94 93 92 8 7 6 5 4 3 Interpretation of the printing code: the rightmost double-digit number is the year of the book’s printing; the rightmost single-digit number, the number of the book’s printing. For example, a printing code of 92-1 shows that the first printing of the book occurred in 1992. Composed in AGaramond and MCPdigital by Prentice Hall Computer Publishing. Screen reproductions in this book were created by means of the program Collage Plus, from Inner Media, Inc., Hollis, NH. Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Introduction v C C C C C C C C C C Publisher Richard K. Swadley Acquisitions Manager Jordan Gold Managing Editor Neweleen A. Trebnik Acquisitions Editor Stacy Hiquet Production Editor Mary Corder Technical Reviewer Timothy C. Moore Editorial Assistants Rosemarie Graham Lori Kelley Formatter Pat Whitmer Production Director Jeff Valler Production Manager Corinne Walls Imprint Manager Matthew Morrill Proofreading/Indexing Coordinator Joelynn Gifford Production Analyst Mary Beth Wakefield Book Design Michele Laseau Cover Art Tim Amrhein Graphic Images Specialist Dennis Sheehan Production Katy Bodenmiller Christine Cook Lisa Daugherty Denny Hager Carla Hall-Batton John Kane Roger Morgan Juli Pavey Angela Pozdol Linda Quigley Michele Self Susan Shepard Greg Simsic Alyssa Yesh Index Hilary Adams Advanced C vi About the Author Peter Hipson and his wife live and work in New Hampshire. He has worked with computers since 1972, in hardware design and software development. He has developed numerous software programs for both PCs and larger systems. He holds patents in the field of CPU design and has been involved with microcomputers since their inception. Peter is the developer of the Windows applications STARmanager and STARmanager A/E. You can contact Peter Hipson at P.O. Box 88, West Peterborough, NH, 03468. Enclosing an SASE greatly enhances the likelihood of a reply. To Bianca, who has shown me what great fun it is having a granddaughter. Introduction vii C C C C C C C C C C Overview Introduction xxiii Part I Honing Your C Skills 1 1 The C Philosophy 3 2 Data Types, Constants, Variables, and Arrays 19 3 Pointers and Indirection 65 4 Special Pointers and Their Usage 99 5 Decimal, Binary, Hex, and Octal 139 6 Separate Compilation and Linking 161 Part II Managing Data in C 189 7 C Structures 191 8 Dynamic Memory Allocation 227 9 Disk Files and Other I/O 249 10 Data Management: Sorts, Lists, and Indexes 321 Part III Working with Others 433 11 C and Other Langauages 435 12 C and Databases 467 13 All About Header Files 497 Advanced C viii Part IV Documenting the Differences 519 14 ANSI C’s Library Functions 521 15 Preprocessor Directives 621 16 Debugging and Efficiency 641 Part V Appendixes 677 A The ASCII Character Set 679 B Compiler Variations 681 C Introduction to C++ 695 D Function/Header File Cross Reference 723 Index 741 Introduction ix C C C C C C C C C C Contents Introduction xxiii Part I: Honing Your C Skills 1 1 The C Philosophy 3 A Brief History of C and the Standard 3 A Programming Style 11 Memory Models 17 Summary 18 2 Data Types, Constants, Variables, and Arrays 19 Data Types 19 Constants 25 Definitions versus Declarations 29 Declarations 30 Definitions 33 Variables 35 Variable Types and Initializing Variables 35 Scope (Or I Can See You) 37 Life Span (Or How Long Is It Going To Be Here?) 39 Type Casting 41 Arrays 46 Declaration of Arrays 46 Definition of an Array 47 Array Indexing 48 Using Array Names as Pointers 55 Strings: Character Arrays 56 Using Arrays of Pointers 58 Summary 62 Advanced C x 3 Pointers and Indirection 65 Pointers, Indirection, and Arrays 65 Pointers 66 Indirection 69 An Example of Pointers, Indirection, and Arrays 69 Character Arrays and Strings 74 Indirection to Access Character Strings 79 Protecting Strings in Memory 90 Ragged-Right String Arrays 92 Summary 98 4 Special Pointers and Their Use 99 Command Line Arguments 99 Function Pointers 114 Menus and Pointers 120 State Machines 135 Summary 137 5 Decimal, Binary, Hex, and Octal 139 Decimal 139 Binary 141 Hex 142 Octal 144 Looking at a File 146 Bit Operators 154 Bit Fields 155 Summary 158 6 Separate Compilation and Linking 161 Compiling and Linking Multiple Source Files 162 Compiling Multifile Programs 164 Linking Multifile Programs 164 Using #include 166 External Variables 171 Using an Object Library Manager 181 Using MAKE Files 182 Summary 186 [...]... Evening”) and public radio station WGBH for providing all the jazz Thank you all xxi Advanced C xxii Introduction CCC CCC C CC C Introduction C has become one of the most frequently used computer languages The first C language was developed by Dennis Ritchie at Bell Laboratories in 1972 and ran on a DEC PDP-11 The ANSI standard for C, which replaced the standard written by Kernighan and Ritchie in 1978,... only once or twice 4 C CC2 CCC C CC Data Types, Constants, Variables, and Arrays 2 CCC CCC C CC Data Types, Constants, Variables, and Arrays The C language offers a number of data types, which can be used for constants, variables, and arrays This chapter helps you become more familiar with data objects and how to use them Data Types The C language supports a number of data types, all of which are necessary... Skills 1 Advanced C 2 C CC1 CCC C CC The C Philosophy 1 CCC CCC C CC The C Philosophy C probably wasn’t your first computer language Mine was FORTRAN, and many other people began their study of computer language with either BASIC or PASCAL No matter which language was your first, you probably will spend much time programming in C from now on This chapter covers a number of introductory topics A Brief... Note on Practicing C You can read, attend lectures, or discuss a subject, but as the saying goes, “practice makes perfect.” xxiv Introduction CCC CCC C CC C Do not be afraid to practice with the programs in this book But practice does not mean copying a program from the diskette, compiling it, and running it Change the example programs Make them do things they weren’t intended to do and learn from your... environments such as database programs Part IV is a reference section that covers the header files, the intrinsic functions, the preprocessor, and some performance and debugging techniques Part V xxiii Advanced C Introduction (the appendixes) contains an ASCII table, information about different compilers, an introduction to C+ +, and a cross-reference of functions and their header files Many chapters contain... 625 The #error Directive 628 The #include Directive 629 The #if Directive 629 The #ifdef Directive 630 The #ifndef Directive 631 The #else Directive 632 The #elif Directive 633 The #endif Directive 633 xviii TableIntroduction of Contents CCC CCC C CC C The #line Directive 634 The #pragma Directive 635 The message... three letters indicate the size of the floating-point object: DBL_ for a double, FLT_ for a float, and LDBL_ for a long double Table 2.4 C s floating-point limits identifiers, from float.h Identifier Description DBL_DIG 22 Value 15 Number of decimal digits of precision CCC CCC C CC Data Types, Constants, Variables, and Arrays 2 Identifier Value Description DBL_EPSILON 2.2204460492503131e-016 Smallest... Classes 714 D Function /Header File Cross Reference 723 Index 741 xx Introduction CCC CCC C CC C Acknowledgments I would like to offer my thanks to the following organizations and people for their support, help, guidance, and enthusiasm The Sams editorial and production staff, especially Gregory Croy, Stacy Hiquet, Susan Pink, Mary Corder, and Rebecca Whitney, all who put... backups often and program away Because C is a powerful language and many of us are programming on PCs using DOS (which has very poor memory protection), be careful; it is easy to trash the disk Good luck improving your C programming skills, have fun writing your software, and remember Peter s rule: Back up your disk frequently! xxv Advanced C xxvi Table of Contents CCC CCC C CC C Part I Honing Your C. .. good book I would also like to thank Timothy C Moore, who did the technical editing Borland International Inc., Microsoft Corporation, and Watcom Products, Inc., have provided valuable support and assistance Thanks to William Colley, III, and the C User’s Group, for the Highly Portable Utilities (CUG-236) files that are included on the sample source diskette Eric Jackson (“Eric in the Evening”) and

Ngày đăng: 19/03/2014, 14:12

Xem thêm: Peter d hipson - advanced c

TỪ KHÓA LIÊN QUAN

Mục lục

    Part I Honing Your C Skills

    Chapter 1 The C Philosophy

    Chapter 2 Data Types, Constants, Variables, and Arrays

    Chapter 3 Pointers and Indirection

    Chapter 4 Special Pointers and Their Use

    Chapter 5 Decimal, Binary, Hex, and Octal

    Part II Managing Data in C

    Chapter 8 Dynamic Memory Allocation

    Chapter 9 Disk Files and Other I/O

    Chapter 10 Data Management: Sorts, Lists, and Indexes

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN