Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

winggx

macrumors newbie
Original poster
Feb 2, 2010
2
0
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....
thanks
 
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.
 
Go to developer.apple.com 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...
 
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....
thanks

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
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.