New to writing c on a mac, need some advice/help

Discussion in 'Mac Programming' started by winggx, Feb 2, 2010.

  1. winggx macrumors newbie

    Feb 2, 2010
    Hello everyone, my computer science class started to teach me c program now, the school website has posted some methods to write c and compile them. Such as using vim, emacs, jedit, using gedit in UNIX etc...

    I tried and it worked, but I think it is quite complicated... I heard that c program can be written in Xcode, I installed it on my mac with the CD...

    The problem is, how do I run it? Is Xcode an IDE?
    If yes, is there any online tutorial that teach me how to set it up?

    I am able to save a .c file but I just don't know how to run it....
  2. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    Open the Terminal application and then use them there.

    In order to actually compile a program you need to get the latest version of Xcode from Apples website (the one on the DVDs is already out of date) and install that as the compilers are not included with Mac OS X by default.

    Other than that it should be exactly the same as any other UNIX environment.

    P.S: If you want to save yourself a smeg load of frustration use nano instead of vim or emacs.
  3. gnasher729 macrumors P6


    Nov 25, 2005
    Go to and get a free ADC account. Then start looking around on their site.

    On the other hand, you could just start XCode, then create a new project of type "Command Line Tool" for C++. You have to get used to figure things out for yourself if you want to go into software development, so if you can't manage to do this, well...
  4. ViViDboarder macrumors 68040


    Jun 25, 2008
    XCode is an IDE. It's very nice but if you want to use what you're familiar with then you can just install the command line tools as mentioned.

    I really like using vim actually, but I would recommend trying out TextWrangler. It is really barebones and does auto indents, code coloring, bracket highlighting, etc... Then you can still use Terminal to compile applications with gcc.

    Also, you can use XCode as an editor only. You can just edit single files in XCode and compile them via the command line very nicely actually. I find XCode's editor also very nice but for things like C and C++ I usually end up using TextWrangler. I just mention it as an option.

    If you do really want to stay on the command line, I recommend reading up on setting up your vim environment with a .vimrc file. You can do so much with vim it's crazy. I have mine set up with highlighting, auto indents, tab switching and more. I can post my rc file here if you want it too. :D
  5. milbournosphere macrumors 6502a


    Mar 3, 2009
    San Diego, CA
    I second TextWrangler as an editor. It uses syntax coloring, which I find very useful. However, I still use gcc to complile and then run my code from the terminal. Vim is a mess for the beginner, I would try to avoid it as you will probably spend as much time learning the features of vim as you would learning the language that you are coding. Nano or pico are also good editing tools to use from the command line if that's more your style.

    Of course, if you want an IDE, Xcode is the choice for you. Its debugging features are great.

Share This Page