Forums | MacLife

You are not logged in.

#1 2008-01-15 1:47 am

loaf
Member
From: Vermont
Registered: 2005-05-21
Posts: 43
Website

basic question about programming in C

I wrote a simple hello world program in C with TextEdit.  Saved it as a text file (not RTF) and used .c as the file extension.  Then went over to the Terminal to compile and run it.  I typed in cc hello.c and the error that I got told me that cc was a bad command.  Why?  I thought that's what you did to compile a program in Terminal.  What am I doing wrong?  Is there a development pack that I didn't install somewhere along the way?

FYI, it's a brand new 13" MacBook running Leopard.

Offline

 

#2 2008-01-15 1:50 am

Miles
Now I fight for wisdom!
Administrator
From: Michigan
Registered: 2001-07-21
Posts: 4496
Website

Re: basic question about programming in C

Yeah, you need to install the Xcode tools.  I'm not sure where they are on computers now; they used to be in /Applications/Installers/

Offline

 

#3 2008-01-15 3:15 am

akb825
ph34r teh master sword
From: In a secluded room
Registered: 2003-12-25
Posts: 6351
Website

Re: basic question about programming in C

Just FYI, TextEdit is a horrible program to edit code in. I suggest using Vim, emacs, or XCode (once you install it) to edit your code, since they will all provide syntax highlighting and extra features to help when you're writing code. You can also install a graphical version of Vim at (http://macvim.org/). There are other programs you can try, some are free, some are not. If you're going to make any projects with multiple source files, I would recommend XCode since it's a full featured IDE.


My software

"Standards are for n00bs!!!" -Microsoft

Offline

 

#4 2008-01-15 5:06 am

Alien
FF
Administrator
From: Republic of Amsterdam
Registered: 1999-07-05
Posts: 16608
Website

Re: basic question about programming in C

Syntax colouring is for wimps. Green on black, that's where it's at!

,xtG
.tsooJ

Offline

 

#5 2008-01-15 5:38 am

loaf
Member
From: Vermont
Registered: 2005-05-21
Posts: 43
Website

Re: basic question about programming in C

Miles wrote:

Yeah, you need to install the Xcode tools.  I'm not sure where they are on computers now; they used to be in /Applications/Installers/

Ah, thanks!  I'll check out my install disc when I get home.

And yeah, I'm not going to use TextEdit for anything.  I'm starting a C class today and just wanted to give the MacBook a try with a simple hello world program.

Thanks for the info!

Offline

 

#6 2008-01-15 7:36 am

Booksley
Planely insane!
From: Toronto, Ontario
Registered: 2001-02-16
Posts: 4826

Re: basic question about programming in C

TextMate destroys all other text editors! wink

Everyone has their own text editors that they like; find one, and stick with it.

Offline

 

#7 2008-01-24 7:06 pm

Light Speed
Doubter of Einstein
Registered: 2002-08-17
Posts: 3693

Re: basic question about programming in C

akb825 wrote:

You can also install a graphical version of Vim at (http://macvim.org/).

Didn't know about this version. Thanks!

And yeah green on black makes me happy too big_smile

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson