ebook img

C Programming Faqs: Frequently Asked Questions PDF

436 Pages·1995·17.84 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 Programming Faqs: Frequently Asked Questions

C Programming FAQs Frequently Asked Questions Steve Summit TT Addison-Wesley Publishing Company Reading, Massachusetts • Menlo Park, California • New York Don Mills, Ontario • Wokingham, England • Amsterdam • Bonn Sydney • Singapore • Tokyo • Madrid • San Juan • Milan • Paris ! °\°\C \ Sponsoring Editor: Deborah R. Lafferty Production Supervisor: Nancy H. Fenton Marketing Manager: Bob Donegan Senior Manufacturing Manager: Roy E. Logan Project Manager: Diane B. Freed Copyeditor: Evelyn W. Pyle Cover Designer: Diana C. Coe Cover Art: Susan Cyr Text Designer: Ron Kosciak Library of Congress Cataloging-in-Publication Data Summit, Steve. C programming FAQs / Steve Summit, p. cm. Includes bibliographical references and index. ISBN 0-201-84519-9 1. C (Computer program language) I. Title. QA76.73.C15S86 1996 005.13'3-dc20 95-39682 CIP The programs and applications presented in this book have been included for their instructional value. They have been tested with care, but are not guaranteed for any particular purpose. The publisher and author do not offer any warranties or representations, nor do they accept any liabilities with respect to the programs or applications. Access the latest information about Addison-Wesley books from our Internet gopher site or from our World Wide Web page: gopher aw.com http:/ /www.aw.com/cseng/ © 1996 by Addison-Wesley Publishing Company, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior written permission of the author. Printed in the United States of America. 123456789 10—CRW—99 98 97 96 95 This book is dedicated to C programmers everywhere. Digitized by the Internet Archive in 2019 with funding from Kahle/Austin Foundation https://archive.org/details/cprogrammingfaqsOOOOsumm Contents Questions xi Preface xxxi Introduction XXXV About This Book XXXV Question Format xxxvii Code Samples xxxviu Organization xxxviii 1. Declarations and Initializations 1 Basic Types 1 Pointer Declarations 5 Declaration Style 6 Storage Classes 8 Typedefs 10 The const Qualifier 14 Complex Declarations 15 19 Array Sizes Declaration Problems 21 Namespace 22 Initialization 26 V CONTENTS 2. Structures, Unions, and Enumerations 30 Structure Declarations 31 Structure Operations 36 Structure Padding 39 Accessing Members 40 Miscellaneous Structure Questions 42 Unions 43 Enumerations 44 Bitfields 46 3. Expressions 48 Evaluation Order 48 Other Expression Questions 57 Preserving Rules 61 4. Pointers 65 Basic Pointer Use 65 Pointer Manipulations 67 Pointers as Function Parameters 69 Miscellaneous Pointer Use 74 5. Null Pointers 77 Null Pointers and Null Pointer Constants 78 The NULL Macro 81 Retrospective 86 What’s Really at Address 0? 90 6. Arrays and Pointers 93 Basic Relationship of Arrays and Pointers 94 Arrays Can’t Be Assigned 97 CONTENTS vii Retrospective 99 Pointers to Arrays 101 Dynamic Array Allocation 104 Functions and Multidimensional Arrays 108 Sizes of Arrays 112 7. Memory Allocation 114 Basic Allocation Problems 114 Calling malloc 119 Problems with malloc 123 Freeing Memory 125 Sizes of Allocated Blocks 129 Other Allocation Functions 130 8. Characters and Strings 135 9. Boolean Expressions and Variables 141 10. C Preprocessor 146 Macro Definitions 147 Fleader Files 152 Conditional Compilation 155 Fancier Processing 159 Macros with Variable-Length Argument Lists 162 11. ANSI/ISO Standard C 167 168 The Standard Function Prototypes 170 173 The const Qualifier CONTENTS VIII Using main () 176 Preprocessor Features 178 Other ANSI C Issues 181 Old or Nonstandard Compilers 185 Compliance 188 12. The Standard I/O Library 191 Basic I/O 192 printf Formats 195 scanf Formats 199 scanf Problems 202 Other stdio Functions 206 Opening and Manipulating Files 211 Redirecting stdin and stdout 214 “Binary” I/O 216 13. Library Functions 221 String Functions 222 Sorting 228 Date and Time 233 Random Numbers 237 Other Library Functions 245 14. Floating Point 248 15. Variable-Length Argument Lists 257 Calling Varargs Functions 258 Implementing Varargs Functions 260 Extracting Variable-Length Arguments 266 Flarder Problems 269

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.