C

SAbsar

Mac Graduate
At college, we need to learn C language, but I havent found a C IDE to use just plain old C on my mac. I've tried the project builder, and used the "File -> New File -> C File" option, but there is NO way to run that file!! :(

Is there a way i can use just plain old C on my mac??
 
emacs
gcc
gdb
make

Or Project Builder ->File->New Project->Tools -> Standard Tool

Either works just fine
 
What do you mean by "run" a file? Do you mean you want to open it in a simple editor, or do you want to run it as a program? The first should be accomplishable using something like TextEdit, and the second requires Project Builder (or other development tool) to compile.
 
With my C++ book for CS at college I can run them fine in Project Builder. Did you try running the default script for the project? Maybe it's your code...? Or it's Windows only C code you're using?
 
If you mean compile, in the terminal, type: "cc <file name>" without the quotation marks and replace <filename> with,...*drum roll*,...the path to the file you want to compile. The resulting executable will be in your Home directory labeled a.out

IPluris's suggestion is better because you have access to all off ProjectBuilder's features.
 
Ive tried using the project builder,but i cant use several functions that we've been taught in college.. such as getch().... ??? :(
 
Make sure you're including all necessary files. But yea they're probably Windows only then, or not included in OS X?
 
Yeah, OS X only has the "standard" C libraries installed. Windows has some custom ones. Usually, you can find something in the standard libraries that does the same (or almost the same) thing as the Windows function does...sometimes you can't.
 
should getch() be getchar()? or getc()?

These would be from the standard libraries.

This is what I do.
I use Project Builder and create a new file with . . . File -> New File. Select C from the list. This will allow you to create a file (NOT a Project) and it does its color coding thing to help you program.

When you are ready to create an executible, open a terminal window and navigate to the directory that holds your source file.

type the following:

cc -o exec_name sourcefilename.c
That will compile the code or give you error messages. If your code compiles, type the following to execute the file:

./exec_name

That's all there is to it.
 
Back
Top