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

bacon7

macrumors newbie
Original poster
Nov 23, 2005
1
0
Hi, i am not a developer at all, but have been running some numerical models that were written in C by my graduate advisor.

In the past, I have compiled (gcc) on a unix machine with no problems. Using the Xcode interface, I can't get it to read in a ascii file, so the program will not run. Also, i typically run the malloc.h header file, but since it isn't included with mac (i think), it seems that the stlib.h has everyhting that malloc.h has. Basically, my question is how to set up the xcode interace so that I can read in my input files. Like i said, i am not a developer, so i appologize if I sound silly with some of this.

thanks
mike
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
You probably are reading in the file with a bad path. We can't do much unless you post code and give a more specific example really...

BTW, if you're not a developer, why use Xcode? For plain ol' C/C++ console apps GCC/Terminal is easier.
 

Jordan72

macrumors member
Nov 23, 2005
88
0
In Xcode:

1. Start up Xcode.

2. From the File menu, select New Project.

A window named Assistant will appear.

3. Under the Command Line Utility section pick select Standard Tool, then press the next button.

4. Name your project and press the Finish button.

5. Find the file main.c and double click on it.

6. Now, paste your code in here. (If you have multiple files, you'll have to do something else, just let me know.)

7. Under the Build menu, select Build. This will compile your code.

If you have any errors, just let me know. I may be able to help out more.

In Terminal:

1. Start the Terminal program located on your Mac.

2. Make sure you are in the directory where you c file exists for this explanation.

3. Your file should have a .c extension. I.e., myCodeToBeCompiled.c

4. Type in gcc yourCode.c -o "myExecutable"

5. Let me know if you get any errors.

6. If not, now type ./myExecutable

This will make your program run.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.