PDA

View Full Version : Basic C programming with Xcode




ilyaclark
Nov 2, 2009, 08:57 PM
I'm learning C in university and need to create a simple program for an assignment. I've searched all over for a compiler like codeblocks or dev C++ to be able to test my work on my macbook. I installed Xcode but I cannot figure out how to simply create a blank file, write up a simple block of C code, compile it and run it. Please advise me on how I can do this... Thx.



lee1210
Nov 2, 2009, 09:16 PM
What version?

On 3.2, new project, choose application on the left, command line tool on the top right, C from the type dropdown.

If it's really a simple assignment, i'd stick to a text editor and gcc, though.

-Lee

SatyMahajan
Nov 2, 2009, 09:35 PM
1. Launch XCode. (I'm assuming you have 3.2.1)
2. File > New Project (or off of the welcome screen)
3. On the left where it says Mac OS X, select Application
4. On the right pane, select Command Line Tool
5. Underneath the icons, where it says "Type" make sure C is selected
6. Click Choose...
7. Name your project
8. Select main.c, enter your code
9. Click Build and Run
10. Open the Console (via Run > Console) to see the output of the program.

Good luck!

ilyaclark
Nov 2, 2009, 11:06 PM
10. Open the Console (via Run > Console) to see the output of the program.

That solves it!!

Thank you very much ByteOfApple!!