Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. Thinking in Code: Basic C > Example: FirstProgram

2.5. Example: FirstProgram

Now you’re going to take everything we’ve learned about types, variables, and functions and put together a small sample program that displays values on the command line in the Terminal. For this example, I’m going to have you use Xcode for editing the files, but use the command line to actually compile the program. In addition to giving us a bit of insight about what Xcode is doing behind the scenes, it will also help us stay focused on the basics of C.

Go to your CocoaBook folder in the Finder. If you haven’t created the CocoaBook folder in your home directory yet, do so now. Then, create a new subfolder inside CocoaBook called ch02. Now open Xcode and choose File New File. In the template window, choose Mac OS X C and C++ C File, then click Next. See Figure 2-3.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial