← Programming the Macintosh in C 1986

Programming the Macintosh in C 1986

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

Programming the Macintosh™ in C Bryan J. Cummings Lawrence J. Pollack SYBEX

A book cover with large orange title lettering on a dark blue background, a streaking comet-like shape with a large stylized letter C at lower right, and a SYBEX logo at lower left over a cloudy sky.

Reading notes: The trademark symbol after Macintosh is small and rendered as ™; transcribed as printed. Author names are set in smaller orange type over the illustration and are legible.

Languages
English
PDF page 1

Programming the Macintosh™ in C Bryan J. Cummings Lawrence J. Pollack SYBEX

A book cover with bold orange title text on a dark blue night-sky background, with a large metallic letter C rendered with streaking light trails and a SYBEX logo in the lower left corner over clouds.

Reading notes: Trademark symbol after Macintosh is small and may be read as ™ at the top right of the title.

Languages
English
PDF page 2

The image is a entirely blank white page with no visible artwork, layout, or printed content.

PDF page 3

PROGRAMMING THE MACINTOSHTM IN c BRYAN ...J. CUMMINGS LAWRENCE ...J. POLLACK Berkeley • Paris • Dusseldort • London

Reading notes: Author names are partly spaced or separated by ellipsis-like characters (BRYAN J. CUMMINGS, LAWRENCE J. POLLACK); spelling preserved as printed.

Languages
English
PDF page 4

Cover art by Jean-Francois Penichoux Book design by Lisa Amon We have taken great care in preparing this book. All information is deemed to be accurate at time of publication. All programming examples have been thoroughly tested on a Macintosh with two disk drives, the Consulair Mac C compiler (release 2.0), and the Macintosh Devel- opment System. Aztec C68K compiler is copyrighted by Manx Software Systems. The Consulair Mac C compiler is copyrighted by Consulair Corporation. C/PM-80 and C/PM-86 are trademarks of Digital Research, Inc. Macintosh is a trademark of Apple Computer Incorporated. The Macintosh Development System is copyrighted by Apple Computer Incorporated. MS.DOS is a trademark of Microsoft Corporation. PC-DOS is a trademark of IBM Corporation. UNIX is a trademark of Bell Laboratories. SYBEX is not affiliated with any manufacturer. Every effort has been made to supply complete and accurate information. However, SYBEX assumes no responsibility for its use, nor for any infringements of patents or other rights of third parties which would result. Copyright©1986 SYBEX Inc., 2344 Sixth Street, Berkeley, CA 94710. World rights reserved. No part of this publication may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic or other record, without the prior agreement and written permission of the publisher. Library of Congress Card Number: 85-63244 ISBN 0-89588-328-7 Printed by Haddon Craftsmen Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1

Reading notes: Release number '2.0' for the Consulair Mac C compiler is listed without a clear date context

Printed product names
Aztec C68K compiler · Consulair Mac C compiler · Macintosh Development System · C/PM-80 · C/PM-86 · Macintosh · MS.DOS · PC-DOS · UNIX
Printed dates
1986 · 2.0
Languages
English
PDF page 5

The image is a plain, entirely blank white page with no artwork, layout, or markings visible.

Reading notes: No visible text found on the page; transcript and printed fields left empty.

PDF page 6

~CKNOWLEDGEMENTS The production of a book requires many steps and many people. For ourselves, and on behalf of DATATECH Publications, the authors would like to thank those people who have helped to create this book. First of all, we want to thank Geta Carlson for her magnificent edito- rial support. At SYBEX, we would like to thank Dr. R. S. Langer and Karl Ray for managing this project so well. Also at SYBEX, thanks to Lisa Amon for her book design, Joel Kroman for technical support, Brenda Walker for typesetting, Dave Clark and Scott Campbell for word processing, Jon Strickland for proofreading, and Jannie Dresser for the tedious task of indexing. B. C. L. P.

Reading notes: Leading word '~CKNOWLEDGEMENTS' appears to be a damaged or OCR-garbled heading; first letter uncertain.

Languages
English
PDF page 7

TABLE OF CONTENTS

TABLE OF CONTENTS INTRODUCTION How This Book Is Organized xv What You Need to Use This Book xvii A REVIEW OF SOME PROGRAMMING BASICS A BRIEF LOOK INSIDE THE COMPUTER 1 The Central Processing Unit 1 Memory 2 NUMBERING SYSTEMS 3 The Binary Numbering System 3 Converting from Binary to Decimal 4 Converting from Decimal to Binary 5 Binary Arithmetic 6 Other Numbering Systems: Octal and Hexidecimal 6 How DATA IS STORED 7 How Numbers Are Represented 9 Character Representation 12 AN OVERVIEW OF MEMORY ORGANIZATION 13 Files 15 The Operating System 16 WRITING A PROGRAM 18 The Programming Process 18 Dealing with Errors 19 PROGRAMMING LANGUAGES WHAT PROGRAMMING LANGUAGES DO 23 The Differences Between Programming Languages 26 The Jobs a Language Is Designed For 26 vii ONE TWO

Reading notes: Chapter heading lines 'ONE' and 'TWO' appear without titles Spelling 'Hexidecimal' appears as printed

Languages
English
PDF page 8

viii The Levels of a Language 26 A Language's Special Tools 27 Interpreted vs Compiled Languages 27 THE SPECIAL CHARACTERISTICS OF C 28 Data Storage and Definition 28 Portability 29 Tools for Building Commands 30 Writeability: Structured Programming 30 Readability: Internal Program Documentation 31 DEVELOPING PROGRAMS: SYNTAX, LOGIC, AND THE ROLE OF STATEMENTS 32 The Programmer's Axioms 32 The Syntax of C 33 Basic Programming Logic 36 Developing a Program Statement 36 INTRODUCTION TO USING C USING COMMENTS TO OUTLINE YOUR PROGRAM 39 CREATING, COMPILING, AND EXECUTING SOURCE CODE 40 BASIC OPERATORS 44 Arithmetic Operators 44 Combined Forms of Arithmetic and Assignment Operators 46 INTRODUCTION TO DATA TYPES 48 A Sample Program 49 RELATIONAL AND LOGICAL OPERATORS 52 Definition and Background of Logic Statements 52 Forming Logical Expressions 54 CONTROLLING PROGRAM FLOW 55 Control Statements 55 Statement Blocks 55 THREE

Reading notes: Source appears to be a table of contents fragment with no advertised products, prices, or dates; headline is not a primary heading.

Languages
English
PDF page 9

CONDITIONAL EXECUTION STATEMENTS

CONDITIONAL EXECUTION STATEMENTS 56 The IF Statement 56 The IF-ELSE Statement 58 The ELSE-IF Statement 60 The?: Operator 62 REPETITION STATEMENTS 63 The WHILE Statement 63 The FOR Statement 65 The DO-WHILE Statement 67 The CONTINUE Statement 68 The BREAK Statement 69 The SWITCH-CASE-DEFAULT Statement 70 THE GOTO STATEMENT 72 PROGRAMMING TECHNIQUE STRUCTURED PROGRAMMING 75 FUNCTIONS 78 Scoping 80 Local Variables 80 Global Variables 82 Storage Classes 84 PARAMETERS 86 A SAMPLE PROGRAM 88 RETURNED VALUES 90 USING FUNCTIONS 91 Library Functions 92 Our GETNUM() Function 96 RECURSION 97 ix FOUR

Reading notes: Source appears to be a table of contents; heading placement and spacing are inconsistent across lines Spacing between words in some entries is irregular

Languages
English
PDF page 10

x DATA TYPES THE DATA TYPES 103 CONSTANT VALUES 105 DATA TYPE DETERMINATION 106 DATA TYPE CONVERSION 107 DATA STRUCTURES STRUCTURING YOUR DATA 113 WORKING WITH POINTERS AND ADDRESSES 115 The Addresses Operator: & 116 Pointers 116 The Pointer Operator: * 116 A Warning About Pointers 120 Functions and Pointers 121 WORKING WITH ARRAYS 123 What Is an Array? 123 Using Arrays 124 Arrays and Pointers 128 Array and Pointer Arithmetic 130 Array Initialization 131 Strings 132 Multidimensional Arrays 133 Arrays of Pointers 134 Pointers to Functions 135 DATA STRUCTURES 137 Creating Data Structures: STRUCT 138 Pointers to Structures 140 Structures and Functions 141 DATA STRUCTURING TECHNIQUES: A SAMPLE PROGRAM 143 Fields and Unions 154 Th.{' TYPEDEF Facility 157 FIVE SIX

Reading notes: Table of contents text contains irregular spacing and a garbled fragment 'Th.{' near the end Reading order of the list is ambiguous due to extraction

Languages
English
PDF page 11

THE STANDARD LIBRARY

BIT MANIPULATION OPERATORS 159 SUMMING UP 161 THE STANDARD LIBRARY C AND UNIX 166 The Standard Input and Output 166 Portability 167 USING THE STANDARD 1/0 LIBRARY 168 Console Routines 168 Character and String Functions 179 Mathematical Functions 181 Memory Allocation and System Interface Functions 181 ACCESSING FILES FROM WITHIN YOUR PROGRAM 182 Using Disk Files for Input and Output 183 Types of file Access 183 File Functions 184 Stream vs File 1/0 186 Using Standard 1/0 Files 189 Command Line Arguments 192 SEVEN THE MACINTOSH ENVIRONMENT VS THE UNIX ENVIRONMENT 196 A Note About Using Toolbox Routines 197 COMPILING YOUR PROGRAM COMPILING YOUR PROGRAM 201 USING COMPUTER DIRECTIVES 203 The #DEFINE Directive 203 The #INCLUDE Directive 206 Conditional Compilation Directives 207 Miscellaneous Directives 209 DEALING WITH COMPILER ERRORS 211 EIGHT xi

Reading notes: Table of contents layout makes reading order of page numbers and section titles somewhat ambiguous Heading 'COMPILING YOUR PROGRAM' appears twice in succession, possibly a duplicated line

Languages
English