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

Advanced c

801 455 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à bộ sách tiếng anh cho dân công nghệ thông tin chuyên về bảo mật,lập trình.Thích hợp cho những ai đam mê về công nghệ thông tin,tìm hiểu về bảo mật và lập trình.

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 [...]... 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 Skills 1 Advanced C 2 C CC1 CCC C CC The C Philosophy 1 CCC CCC C CC The C Philosophy C probably... really compiler limits; however, because they affect the language, you sometimes must take them into consideration These limits are not usually a problem; in the ten years that I’ve been writing C programs, I’ve run into problems with these limits 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... 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, is only a few years old C s structure is similar to PL/I... 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 mistakes Make backups often and program away Because C is a... #define Directive 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 ...Introduction Table of Contents Part II: Managing Data in C 7 CCC CCC C CC C 189 C Structures 191 Using the struct Keyword 191 Arrays of Structures 195 Structures of Arrays 200 Structures of Structures 203 Bit Fields in Structures 206 Using the typedef Keyword 208 Using the offsetof() Macro 213 Pointers to Structures 216... 255 Maximum unsigned char type CHAR_MIN SCHAR_MIN Minimum char value, if characters are unsigned CHAR_MAX SCHAR_MAX Maximum char value, if characters are unsigned CHAR_MIN 0 If characters are signed continues 21 Part I • Honing Your C Skills Table 2.3 continued Identifier Value Description CHAR_MAX UCHAR_MAX If characters are signed MB_LEN_MAX 1 Maximum number of bytes in multibyte char short int types... integer can hold values between 0 and 65,535 The unsigned modifier can be used with char, long, and short (integer) types Each of the data types (and their modifiers) has a minimum and maximum value (see Table 2.3) Check your compiler documentation because some compilers extend 20 CCC CCC C CC Data Types, Constants, Variables, and Arrays 2 these values Be careful not to assume that a variable created... 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 enormous effort... that Can Go Wrong 462 Looking at Data 463 Names and Limits 465 Summary 465 xii TableIntroduction of Contents 12 CCC CCC C CC C C and Databases 467 Interfacing with dBASE-Compatible Programs 468 Using dBASE Files Directly 468 Reading dBASE and dBASE-Compatible Files 474 Creating dBASE and dBASE-Compatible Files 484 Updating dBASE and dBASE-Compatible . 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. 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

Ngày đăng: 19/03/2014, 13:32

Xem thêm: 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

w