Learn C on the Mac

By David Mark

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.

Full Description

  • ISBN13: 978-1-4302-1809-8
  • User Level: Beginner to Advanced
  • Publication Date: December 11, 2008
  • Available eBook Formats: EPUB, MOBI, PDF
  • Print Book Price: $39.99
  • eBook Price: $27.99
Buy eBook Buy Print Book Add to Wishlist

Related Titles

Full 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

What you’ll learn

  • Master C programming, the gateway to programming your Mac or iPhone
  • Write applications for the Mac OS X interface, the cleanest user interface around
  • Understand variables and how to design your own data structures
  • Work with the file system
  • Connect to data sources and the Internet

Who this book is for

For anyone wanting to learn to program in Mac OS X, including developers new to the Mac, developers new to C, or students entirely new to programming. For anyone who wants to learn how to program their iPhone, this is also the core language primer.

Source Code/Downloads

Downloads are available to accompany this book.

Your operating system can likely extract zipped downloads automatically, but you may require software such as WinZip for PC, or StuffIt on a Mac.

Errata

Please Login to submit errata.

On page 5:

The tools are not free when going through http://developer.apple.com/mac

On page 62:

The line of code
myInt = 27 * 6 % 5
should have its operators evaluated left to right, but the example reverses this order.
The equivalent code is actually
myInt = (27 * 6) % 5

The following line of code
myInt = 27 % 6 * 5
should also have its operators evaluated left to right, but the example reverses the order here too.
The equivalent code is actually
myInt = (27 % 6) * 5

On page 92:
Just checking whether, at the top of the page, it is supposed to say ' ! mySecondInt ', rather than ' ! mySecondBool '...?

On page 93:
Rather than use bool, use:

int nothingElseOn, itsARerun;

nothingElseOn = true; itsARerun = false;
if ( (! itsARerun) || nothingElseOn ) printf( "Let's watch Family Guy!\n" );
else
printf( "Something else is on or I've seen this one.\n" );

On page 199:
Isspace().....returns 0 if the char is either a tab....

It's the contrary, isspace() returns 1 if the char is a tab or space or line feed or....

On page 222:
The semicolon is missing after the right curly brace in the type declaration.

On page 226:
Under "NOTE" author has written the three fields "total 103 bytes" -- should read "total 513 bytes".

On page 236:

At the end of sample type declaration under "Creating a Linked List" the semicolon is missing after the right curly brace.

On page 254:

From the grey box at the top:

As long as the type of the right side is no larger than the type of the left side (as is the case here: an int is at least as large as a char), this won’t be a problem.

This doesn't make sense since the return type of fgetc is an int, which is larger than the char it is getting assigned to, so the type of the right side is larger than the type on the left side.