Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easier way to type and compile C on Mac OS X?

I've just started learning C on Mac OS X. I have downloaded Xcode too.

So far, I have been typing my apps into TextEdit, and then using the Terminal to locate my apps and compile them using gcc hello.c etc.

Is there an easier way (using Xcode perhaps?) to type my code into some form of IDE, and then automate the compiling with a 'compile and run' button or similiar? It seems a bit primitive and tedious using TextEdit and then switching to the Terminal to compile. However, I do not have much experience with lower level languages like C, so I'm unsure if it is even possible.

Thanks

like image 724
alex Avatar asked Jan 31 '26 00:01

alex


2 Answers

Yes that is what XCode is for.

Look at the tutorial on the open screen of XCode (version 3.2.1 for OSX 10.6) This is for objective C but the tools are the same.

Or if the objective C is confusing choose a new project from XCode. File->New Project) choose command line tool as the project type and then choose type as C from the pop up menu

like image 102
mmmmmm Avatar answered Feb 02 '26 13:02

mmmmmm


Xcode will definitely be easier, although for a "hello world"-type project like yours, its advantages may not be obvious. Install it, fire it up, and leave TextEdit behind ...

OTOH, you could edit your source code in vi or emacs (in Terminal), which would avoid having to flip between Terminal and TextEdit. BTW, this is the way development used to be done ...

like image 34
Paul Lalonde Avatar answered Feb 02 '26 12:02

Paul Lalonde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!