Learn C on the Mac
Book information
Description
Considered a classic by an entire generation of Mac programmers, this popular guide has been updated for Mac OS X. Don't know anything about programming? No problem! Acclaimed author Dave Mark starts out with the basics and takes you through a complete course in programming C using Apple's free Xcode tools. This book is perfect for beginners learning to program. It includes Mac OS X examples! Provides best practices for programming newbies Written by the expert on C-programming for the Mac Presents all the basics with a pragmatic, Mac OS X-flavored approach Includes updated source code which is fully compatible with Xcode 4 Learn C on the Mac Copyright Dedication Contents at a Glance Contents About the Author About the Technical Reviewer Acknowledgments Preface Chapter 1: Welcome Aboard Who Is This Book For? The Lay of the Land Chapter 2: Go Get the Tools! Create an ADC Account Download the Tools Installing the Tools Take Tour Tools for a Test Drive The Xcode Welcome Screen Creating Your First Xcode Project Saving Your New Project Running the Project Your First Program Downloading the Book Projects Let's Move On Chapter 3: Programming Basics Programming Some Alternatives to C What About Objective-C, C++, and Java? What's the Best Language for Programming the Mac or iPhone? The Programming Process Source Code Compiling Your Source Code What's Next? Chapter 4: C Basics - Funtions C Functions The Funtion Definition Syntax Errors and Algorithms Calling a Function A Brief History of C The Standard Library Exploring Unix and Your Mac's Built-In Manual Same Program, Two Functions The hello2 Project The hello2 Source Code Running hello2 Let's Do That Again, Again, Again Generating Some Errors C Is Case Sensitive What's Next? Chapter 5: C Basics - Variables and Operators An Introduction to Variables Working with Variables Variable Names The Size of a Type Bytes and Bits Going from 1 Byte to 2 Bytes Operators The +, -, ++, and -- Operators The += and -= Operators The *, /, *=, and /= Operators Using Parentheses Operator Precedence Sample Programs Opening operator.xcodeproj Stepping Through the operator Source Code Opening postfix.xcode Stepping Through the postfix Source Code Backslash Combinations Support for Backslash Combinations Running slasher Stepping Through the slasher Source Code Building slasher the Unix Way Which Compiler Did You Run? Running the Unix Version of slasher Sprucing Up Your Code Source Code Spacing Comment Your Code The Curly Brace Controversy What's Next? Chapter 6: Controlling Your Program's Flow Flow Control The if Statement Expressions True Expressions Comparative Operators Logical Operators truthTester.xcodeproj Compound Expressions Statements The Curly Braces Where to Place the Semicolon The Loneliest Statement The while Statement The for Statement loopTester.xcodeproj The do Statement The switch Statement Breaks in Other Loops isOdd.xcodeproj Stepping Through the isOdd Source Code nextPrime.xcodeproj Stepping Through the nextPrime Source Code What's Next Chapter 7: Pointers and Parameters What Is a Pointer? Why Use Pointers? Checking Out of the Library Pointer Basics Variable Addresses The & Operator Declaring a Pointer Variable Function Parameters What Are Function Parameters? Variable Scope How Function Parameters Work Parameters Are Temporary The Difference Between Arguments and Parameters What Does All This Have to Do with Pointers? Global Variables and Function Returns Global Variables Adding Globals to Your Programs Function Returns printf() Returns a Value Danger! Avoid Uninitialized Return Values! To Return or Not to Return? More Sample Programs listPrimes.xcode power.xcodeproj Using the Debugger What's Next? Chapter 8: Variable Data Types Data Types Beyond int floatSizer Walking Through the floatSizer Source Code The Integer Types Type Value Ranges Memory Efficiency vs. Safety Working with Characters The ASCII Character Set ascii.xcodeproj Stepping Through the ascii Source Code Arrays Why Use Arrays? dice.xcode Stepping Through the dice Source Code Danger, Will Robinson! Text Strings A Text String in Memory nameBad.xcodeproj Stepping Through the nameBad Source Code The Input Buffer On with the Program The Problem with nameBad The nameGood Source Code The #define Directive Function-Like #define Macros wordCount.xcodeproj Stepping Through the wordCount Source Code What's Next? Chapter 9: Designing Your Own Data Structures Bundling Your Data Model A: Three Arrays multiArray.xcodeproj Stepping Through the multiArray Source Code Getting Rid of the Extra Carriage Return Adding Error Handling Walking Through the multiArrayWithErrCode Source Code Finishing Up With Model A Model B: The Data Structure Approach structSize.xcodeproj Stepping Through the structSize Source Code Passing a struct As a Parameter Passing a Copy of the struct paramAddress.xcodeproj struct Arrays Allocating Your Own Memory Using malloc() free() Keeping Track of That Address! Working with Linked Lists Why Use Linked Lists? Creating a Linked List dvdTracker.xcodeproj Stepping Through the dvdTracker Source Code What's Next? Chapter 10: Working with FIles What Is a FIle? Working with Files: File Basics Understanding File Names Opening and Closing a FIle Reading a File printFile.xcodeproj Stepping Through the printFile Source Code stdin, stdout, and stderr Working with Files: Writing Files Writing to a File dvdFiler.xcodeproj Creating a New Source Code File Exploring dvdData Running dvdFiler Stepping Through the dvdFiler Source Code Working with Files: Fancier File Manipulation The Update Modes Random File Access Using Random Access Functions dinoEdit.xcodeproj Stepping Through the dinoEdit Source Code What's Next? Chapter 11: Advanced Topics Typecasting Cast with Care Casting with Pointers Unions Why Use Unions? Function Recursion A Recursive Approach Binary Trees Searching Binary Trees Recursion and Binary Trees Function Pointers Initializers An Initializon Example The Remaining Operators Creating Your Own Types Enumerated Types Static Variables More on Strings strncpy() strncat() strncmp() strlen() More Standard Library Information What's Next? Chapter 12: Where Do You Go from Here? The Mac User Interface Objective-c and Cocoa Learning Cocoa One Last Bit of Code Go Get 'Em Appendix: Answers to Exercises Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Index
Similar books
Learn C++ on the Macintosh: Includes Special Version of Symantec's C++ for Macintosh
1993 · PDF
Beginning iOS 5 Development: Exploring the iOS SDK
2011 · PDF
More iPhone 3 Development: Tackling iPhone SDK 3
2009 · PDF
Beginning iPhone 3 Development: Exploring the iPhone SDK
2009 · PDF
Learn C on the Mac
2008 · PDF
Learn C on the Mac
2008 · PDF
More iPhone 3 Development: Tackling iPhone SDK 3
2009 · PDF
Beginning iOS 5 Development: Exploring the iOS SDK
2011 · PDF