ebook img

C For Dummies, 2nd Edition - shrani.si PDF

411 Pages·2004·7.93 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 For Dummies, 2nd Edition - shrani.si

01 570684 FM.qxd 3/31/04 2:50 PM Page iii C FOR DUMmIES ‰ 2 ND EDITION by Dan Gookin 01 570684 FM.qxd 3/31/04 2:50 PM Page ii 01 570684 FM.qxd 3/31/04 2:50 PM Page i C FOR DUMmIES ‰ 2 ND EDITION 01 570684 FM.qxd 3/31/04 2:50 PM Page ii 01 570684 FM.qxd 3/31/04 2:50 PM Page iii C FOR DUMmIES ‰ 2 ND EDITION by Dan Gookin 01 570684 FM.qxd 3/31/04 2:50 PM Page iv C For Dummies®, 2nd Edition Published by Wiley Publishing, Inc. 111 River Street Hoboken, NJ 07030-5774 Copyright © 2004 by Wiley Publishing, Inc., Indianapolis, Indiana Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada 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, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4447, e-mail: [email protected]. Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP­ RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CON­ TENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDER­ STANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPE­ TENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMA­ TION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at 800-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Control Number: 2004101965 ISBN: 0-7645-7068-4 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 2B/RZ/QU/QU/IN 01 570684 FM.qxd 3/31/04 2:50 PM Page v About the Author Dan Gookin has been writing about technology for 20 years. He has contributed articles to numerous high-tech magazines and written more than 90 books about personal computing technology, many of them accurate. He combines his love of writing with his interest in technology to create books that are informative and entertaining, but not boring. Having sold more than 14 million titles translated into more than 30 languages, Dan can attest that his method of crafting computer tomes does seem to work. Perhaps Dan’s most famous title is the original DOS For Dummies, published in 1991. It became the world’s fastest-selling computer book, at one time moving more copies per week than the New York Times number-one best seller (although, because it’s a reference book, it could not be listed on the NYT best seller list). That book spawned the entire line of For Dummies books, which remains a publishing phenomenon to this day. Dan’s most recent titles include PCs For Dummies, 9th Edition; Buying a Com­ puter For Dummies, 2004 Edition; Troubleshooting Your PC For Dummies; Dan Gookin’s Naked Windows XP; and Dan Gookin’s Naked Office. He also pub­ lishes a free weekly computer newsletter, “Weekly Wambooli Salad,” full of tips, how-tos, and computer news. He also maintains the vast and helpful Web page www.wambooli.com. Dan holds a degree in communications and visual arts from the University of California, San Diego. He lives in the Pacific Northwest, where he enjoys spending time with his four boys in the gentle woods of Idaho. 01 570684 FM.qxd 3/31/04 2:50 PM Page vi Publisher’s Acknowledgments We’re proud of this book; please send us your comments through our online registration form located at www.dummies.com/register/. Some of the people who helped bring this book to market include the following: Acquisitions, Editorial, and Media Production Development Project Coordinator: Maridee Ennis Project Editor: Rebecca Whitney Layout and Graphics: Amanda Carter, Acquisitions Editor: Gregory Croy Andrea Dahl, Lauren Goddard, Denny Hager, Michael Kruzil, Technical Editors: Greg Guntle, Kip Warner Lynsey Osborn (http://TheVertigo.com) Proofreaders: Laura Albert, Andy Hollandbeck, Editorial Manager: Carol Sheehan TECHBOOKS Production Services Media Development Supervisor: Indexer: Johnna VanHoose Richard Graves Editorial Assistant: Amanda M. Foxworth Cartoons: Rich Tennant (www.the5thwave.com) Publishing and Editorial for Technology Dummies Richard Swadley, Vice President and Executive Group Publisher Andy Cummings, Vice President and Publisher Mary C. Corder, Editorial Director Publishing for Consumer Dummies Diane Graves Steele, Vice President and Publisher Joyce Pepple, Acquisitions Director Composition Services Gerry Fahey, Vice President of Production Services Debbie Stailey, Director of Composition Services 01 570684 FM.qxd 3/31/04 2:50 PM Page vii Contents at a Glance Introduction .................................................................1 Part I: Introduction to C Programming............................7 Chapter 1: Up from the Primordial C ...............................................................................9 Chapter 2: C of Sorrow, C of Woe....................................................................................19 Chapter 3: C Straight........................................................................................................29 Chapter 4: C What I/O......................................................................................................39 Chapter 5: To C or Not to C .............................................................................................55 Chapter 6: C More I/O with gets() and puts()..........................................................65 Part II: Run and Scream from Variables and Math ........73 Chapter 7: A + B = C..........................................................................................................75 Chapter 8: Charting Unknown Cs with Variables .........................................................93 Chapter 9: How to C Numbers......................................................................................107 Chapter 10: Cook That C Variable Charred, Please....................................................121 Part III: Giving Your Programs the Ability to Run Amok ............................................................131 Chapter 11: C More Math and the Sacred Order of Precedence ..............................133 Chapter 12: C the Mighty if Command.......................................................................147 Chapter 13: What If C==C? .............................................................................................165 Chapter 14: Iffy C Logic..................................................................................................175 Chapter 15: C You Again ................................................................................................185 Chapter 16: C the Loop, C the Loop++.........................................................................201 Chapter 17: C You in a While Loop...............................................................................215 Chapter 18: Do C While You Sleep................................................................................225 Chapter 19: Switch Case, or, From ‘C’ to Shining ‘c’...................................................239 Part IV: C Level ........................................................251 Chapter 20: Writing That First Function......................................................................253 Chapter 21: Contending with Variables in Functions.................................................265 Chapter 22: Functions That Actually Funct................................................................275 Chapter 23: The Stuff That Comes First ......................................................................293

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.