April 13, 2008
Having switched to a Mac a few months ago, I was interested in finding out how to program in C using the software available on my Mac. Xcode 3.0 does the job. If you want to write a C program, just follow along:
Open Xcode 3.0 and click File > New Project. Select the arrow next to “Command Line Utility” and choose Standard Tool. Give your project a name and a location in which to store all the files that Xcode will build for you.

Now select Window > Organizer. Next, you’ll want to open a finder window and browse for the location of the name of the project folder you created earlier. Drag and drop that folder into the Organizer window. You’ll notice that it shows up there.

Click the arrow next to the project folder to see the files inside this folder. Next, to access the main C file, you can double click the file main.c, or you can click on the bottom icon the furthest to the right to open the editor in the Organizer window.

The next thing you’ll want to do is click the Build button, the one with the hammer. Finally, click the Run button. There you have it: you’re first C program on a Mac.
Leave a Comment » |
C/C++ | Tagged: C, Mac OS X, programming, Xcode |
Permalink
Posted by paintdexter
April 2, 2008
That’s the question I had been asked a few months ago while on the phone with an interviewer from the MathWorks. I didn’t have a clue. All I knew was that you typed it all the time when you wanted to make sure you could use the printing functions in your main function. I finally wanted to put this question to rest, so I did a little research.
The # sign in C++ is a directive that says “handle this with the preprocessor” while the include statement means “make everything in the provided file available to this program” [1].
The “<” and “>” tell the preprocessor that the file located inside the angle brackets is located in the standard search path [1].
We may ask: “Exactly what does the #include do? It copies the content of the file specified inside the quotation marks or the angle brackets, and places it in the file at the location where the #include appears [2].
References:
[1] “What does #include <stdio.h> stand for in c program?” Yahoo! Answers. April 2, 2008. http://answers.yahoo.com/question/index?qid=20080103071957AAKM9jX
[2] “Preprocessor”. April 3, 2008. http://en.wikipedia.org/wiki/Preprocessor
Leave a Comment » |
C/C++ |
Permalink
Posted by paintdexter