Basic C programming with Xcode

Discussion in 'Mac Programming' started by ilyaclark, Nov 2, 2009.

  1. macrumors newbie

    Joined:
    Nov 2, 2009
    #1
    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.
     
  2. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    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
     
  3. macrumors regular

    Joined:
    Apr 26, 2009
    Location:
    Cambridge, MA
    #3
    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!
     
  4. thread starter macrumors newbie

    Joined:
    Nov 2, 2009
    #4
    10. Open the Console (via Run > Console) to see the output of the program.

    That solves it!!

    Thank you very much ByteOfApple!!
     

Share This Page